dbgate-datalib 5.0.8 → 5.1.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/lib/FreeTableGridDisplay.d.ts +8 -4
- package/lib/GridDisplay.d.ts +1 -1
- package/lib/PerspectiveCache.d.ts +39 -0
- package/lib/PerspectiveCache.js +99 -0
- package/lib/PerspectiveConfig.d.ts +85 -0
- package/lib/PerspectiveConfig.js +54 -0
- package/lib/PerspectiveDataLoader.d.ts +9 -0
- package/lib/PerspectiveDataLoader.js +139 -0
- package/lib/PerspectiveDataProvider.d.ts +42 -0
- package/lib/PerspectiveDataProvider.js +181 -0
- package/lib/PerspectiveDisplay.d.ts +55 -0
- package/lib/PerspectiveDisplay.js +229 -0
- package/lib/PerspectiveTreeNode.d.ts +174 -0
- package/lib/PerspectiveTreeNode.js +959 -0
- package/lib/TableGridDisplay.d.ts +8 -4
- package/lib/ViewGridDisplay.d.ts +8 -4
- package/lib/index.d.ts +7 -0
- package/lib/index.js +12 -1
- package/lib/processPerspectiveDefaultColunns.d.ts +4 -0
- package/lib/processPerspectiveDefaultColunns.js +128 -0
- package/lib/tests/PerspectiveDisplay.test.d.ts +1 -0
- package/lib/tests/PerspectiveDisplay.test.js +94 -0
- package/lib/tests/artistDataAlbum.d.ts +20 -0
- package/lib/tests/artistDataAlbum.js +58 -0
- package/lib/tests/artistDataAlbumTrack.d.ts +20 -0
- package/lib/tests/artistDataAlbumTrack.js +79 -0
- package/lib/tests/artistDataFlat.d.ts +10 -0
- package/lib/tests/artistDataFlat.js +23 -0
- package/lib/tests/chinookDbInfo.d.ts +2 -0
- package/lib/tests/chinookDbInfo.js +1775 -0
- package/package.json +9 -4
|
@@ -35,8 +35,8 @@ export declare class TableGridDisplay extends GridDisplay {
|
|
|
35
35
|
isForeignKeyUnique: boolean;
|
|
36
36
|
pairingId?: string;
|
|
37
37
|
columnName: string;
|
|
38
|
-
notNull
|
|
39
|
-
autoIncrement
|
|
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
|
|
75
|
-
autoIncrement
|
|
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;
|
package/lib/ViewGridDisplay.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export declare class ViewGridDisplay extends GridDisplay {
|
|
|
13
13
|
uniquePath: string[];
|
|
14
14
|
pairingId?: string;
|
|
15
15
|
columnName: string;
|
|
16
|
-
notNull
|
|
17
|
-
autoIncrement
|
|
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
|
|
40
|
-
autoIncrement
|
|
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
|
}
|
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,8 @@ 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';
|
|
21
|
+
export * from './processPerspectiveDefaultColunns';
|
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.
|
|
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,8 @@ __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);
|
|
37
|
+
__exportStar(require("./processPerspectiveDefaultColunns"), exports);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MultipleDatabaseInfo, PerspectiveConfig } from './PerspectiveConfig';
|
|
2
|
+
export declare function perspectiveNodesHaveStructure(config: PerspectiveConfig, dbInfos: MultipleDatabaseInfo, conid: string, database: string): boolean;
|
|
3
|
+
export declare function shouldProcessPerspectiveDefaultColunns(config: PerspectiveConfig, dbInfos: MultipleDatabaseInfo, conid: string, database: string): boolean;
|
|
4
|
+
export declare function processPerspectiveDefaultColunns(config: PerspectiveConfig, dbInfos: MultipleDatabaseInfo, conid: string, database: string): PerspectiveConfig;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processPerspectiveDefaultColunns = exports.shouldProcessPerspectiveDefaultColunns = exports.perspectiveNodesHaveStructure = void 0;
|
|
4
|
+
const dbgate_tools_1 = require("dbgate-tools");
|
|
5
|
+
const PerspectiveTreeNode_1 = require("./PerspectiveTreeNode");
|
|
6
|
+
function getPerspectiveDefaultColumns(table, db, circularColumns) {
|
|
7
|
+
const columns = table.columns.map(x => x.columnName);
|
|
8
|
+
const predicates = [
|
|
9
|
+
x => x.toLowerCase() == 'name',
|
|
10
|
+
x => x.toLowerCase() == 'title',
|
|
11
|
+
x => x.toLowerCase().includes('name'),
|
|
12
|
+
x => x.toLowerCase().includes('title'),
|
|
13
|
+
x => x.toLowerCase().includes('subject'),
|
|
14
|
+
// x => x.toLowerCase().includes('text'),
|
|
15
|
+
// x => x.toLowerCase().includes('desc'),
|
|
16
|
+
x => {
|
|
17
|
+
var _a, _b, _c;
|
|
18
|
+
return (_c = (_b = (_a = table.columns
|
|
19
|
+
.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');
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
for (const predicate of predicates) {
|
|
23
|
+
const col = columns.find(predicate);
|
|
24
|
+
if (col)
|
|
25
|
+
return [[col], null];
|
|
26
|
+
}
|
|
27
|
+
if (circularColumns) {
|
|
28
|
+
const keyPredicates = [
|
|
29
|
+
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); },
|
|
30
|
+
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; },
|
|
31
|
+
];
|
|
32
|
+
for (const predicate of keyPredicates) {
|
|
33
|
+
const col = columns.find(predicate);
|
|
34
|
+
if (col)
|
|
35
|
+
return [null, [col]];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return [[columns[0]], null];
|
|
39
|
+
}
|
|
40
|
+
function perspectiveNodesHaveStructure(config, dbInfos, conid, database) {
|
|
41
|
+
var _a;
|
|
42
|
+
for (const node of config.nodes) {
|
|
43
|
+
const db = (_a = dbInfos === null || dbInfos === void 0 ? void 0 : dbInfos[node.conid || conid]) === null || _a === void 0 ? void 0 : _a[node.database || database];
|
|
44
|
+
if (!db)
|
|
45
|
+
return false;
|
|
46
|
+
const table = db.tables.find(x => x.pureName == node.pureName && x.schemaName == node.schemaName);
|
|
47
|
+
const view = db.views.find(x => x.pureName == node.pureName && x.schemaName == node.schemaName);
|
|
48
|
+
if (!table && !view)
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
exports.perspectiveNodesHaveStructure = perspectiveNodesHaveStructure;
|
|
54
|
+
function shouldProcessPerspectiveDefaultColunns(config, dbInfos, conid, database) {
|
|
55
|
+
const nodesNotProcessed = config.nodes.filter(x => !x.defaultColumnsProcessed);
|
|
56
|
+
if (nodesNotProcessed.length == 0)
|
|
57
|
+
return false;
|
|
58
|
+
return perspectiveNodesHaveStructure(config, dbInfos, conid, database);
|
|
59
|
+
}
|
|
60
|
+
exports.shouldProcessPerspectiveDefaultColunns = shouldProcessPerspectiveDefaultColunns;
|
|
61
|
+
function processPerspectiveDefaultColunnsStep(config, dbInfos, conid, database) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const rootNode = config.nodes.find(x => x.designerId == config.rootDesignerId);
|
|
64
|
+
if (!rootNode)
|
|
65
|
+
return null;
|
|
66
|
+
const rootDb = (_a = dbInfos === null || dbInfos === void 0 ? void 0 : dbInfos[rootNode.conid || conid]) === null || _a === void 0 ? void 0 : _a[rootNode.database || database];
|
|
67
|
+
if (!rootDb)
|
|
68
|
+
return null;
|
|
69
|
+
const rootTable = rootDb.tables.find(x => x.pureName == rootNode.pureName && x.schemaName == rootNode.schemaName);
|
|
70
|
+
const rootView = rootDb.views.find(x => x.pureName == rootNode.pureName && x.schemaName == rootNode.schemaName);
|
|
71
|
+
const root = new PerspectiveTreeNode_1.PerspectiveTableNode(rootTable || rootView, dbInfos, config, null, null, { conid, database }, null, config.rootDesignerId);
|
|
72
|
+
for (const node of config.nodes) {
|
|
73
|
+
if (node.defaultColumnsProcessed)
|
|
74
|
+
continue;
|
|
75
|
+
const db = (_b = dbInfos === null || dbInfos === void 0 ? void 0 : dbInfos[node.conid || conid]) === null || _b === void 0 ? void 0 : _b[node.database || database];
|
|
76
|
+
if (!db)
|
|
77
|
+
continue;
|
|
78
|
+
const table = db.tables.find(x => x.pureName == node.pureName && x.schemaName == node.schemaName);
|
|
79
|
+
const view = db.views.find(x => x.pureName == node.pureName && x.schemaName == node.schemaName);
|
|
80
|
+
if (table || view) {
|
|
81
|
+
const treeNode = root.findNodeByDesignerId(node.designerId);
|
|
82
|
+
if (!treeNode) {
|
|
83
|
+
const [defaultColumns] = getPerspectiveDefaultColumns(table || view, db, null);
|
|
84
|
+
return Object.assign(Object.assign({}, config), { nodes: config.nodes.map(n => n.designerId == node.designerId
|
|
85
|
+
? Object.assign(Object.assign({}, n), { defaultColumnsProcessed: true, checkedColumns: defaultColumns }) : n) });
|
|
86
|
+
}
|
|
87
|
+
const circularColumns = treeNode.childNodes.filter(x => x.isCircular).map(x => x.columnName);
|
|
88
|
+
const [defaultColumns, defaultRefs] = getPerspectiveDefaultColumns(table || view, db, circularColumns);
|
|
89
|
+
if (defaultRefs) {
|
|
90
|
+
const childNode = treeNode.childNodes.find(x => x.columnName == defaultRefs[0]);
|
|
91
|
+
if (childNode === null || childNode === void 0 ? void 0 : childNode.designerId) {
|
|
92
|
+
return Object.assign(Object.assign({}, config), { nodes: config.nodes.map(n => n.designerId == childNode.designerId
|
|
93
|
+
? Object.assign(Object.assign({}, n), { isNodeChecked: true }) : n.designerId == node.designerId
|
|
94
|
+
? Object.assign(Object.assign({}, n), { defaultColumnsProcessed: true }) : n) });
|
|
95
|
+
}
|
|
96
|
+
else if (childNode) {
|
|
97
|
+
const [newConfig, nodeConfig] = childNode.ensureNodeConfig(config);
|
|
98
|
+
nodeConfig.isNodeChecked = true;
|
|
99
|
+
return Object.assign(Object.assign({}, newConfig), { nodes: newConfig.nodes.map(n => n.designerId == node.designerId
|
|
100
|
+
? Object.assign(Object.assign({}, n), { defaultColumnsProcessed: true }) : n) });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return Object.assign(Object.assign({}, config), { nodes: config.nodes.map(n => n.designerId == node.designerId
|
|
105
|
+
? Object.assign(Object.assign({}, n), { defaultColumnsProcessed: true, checkedColumns: defaultColumns }) : n) });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
function markAllProcessed(config) {
|
|
112
|
+
return Object.assign(Object.assign({}, config), { nodes: config.nodes.map(x => (Object.assign(Object.assign({}, x), { defaultColumnsProcessed: true }))) });
|
|
113
|
+
}
|
|
114
|
+
function processPerspectiveDefaultColunns(config, dbInfos, conid, database) {
|
|
115
|
+
while (config.nodes.filter(x => !x.defaultColumnsProcessed).length > 0) {
|
|
116
|
+
const newConfig = processPerspectiveDefaultColunnsStep(config, dbInfos, conid, database);
|
|
117
|
+
if (!newConfig) {
|
|
118
|
+
return markAllProcessed(config);
|
|
119
|
+
}
|
|
120
|
+
if (newConfig.nodes.filter(x => x.defaultColumnsProcessed).length <=
|
|
121
|
+
config.nodes.filter(x => x.defaultColumnsProcessed).length) {
|
|
122
|
+
return markAllProcessed(config);
|
|
123
|
+
}
|
|
124
|
+
config = newConfig;
|
|
125
|
+
}
|
|
126
|
+
return markAllProcessed(config);
|
|
127
|
+
}
|
|
128
|
+
exports.processPerspectiveDefaultColunns = processPerspectiveDefaultColunns;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
const processPerspectiveDefaultColunns_1 = require("../processPerspectiveDefaultColunns");
|
|
14
|
+
test('test flat view', () => {
|
|
15
|
+
const artistTable = chinookDbInfo_1.chinookDbInfo.tables.find(x => x.pureName == 'Artist');
|
|
16
|
+
const configColumns = (0, processPerspectiveDefaultColunns_1.processPerspectiveDefaultColunns)((0, PerspectiveConfig_1.createPerspectiveConfig)({ pureName: 'Artist' }), { conid: { db: chinookDbInfo_1.chinookDbInfo } }, 'conid', 'db');
|
|
17
|
+
const root = new PerspectiveTreeNode_1.PerspectiveTableNode(artistTable, { conid: { db: chinookDbInfo_1.chinookDbInfo } }, configColumns, null, null, { conid: 'conid', database: 'db' }, null, configColumns.rootDesignerId);
|
|
18
|
+
const display = new PerspectiveDisplay_1.PerspectiveDisplay(root, artistDataFlat_1.default);
|
|
19
|
+
expect(display.rows.length).toEqual(4);
|
|
20
|
+
expect(display.rows[0].rowData).toEqual(['AC/DC']);
|
|
21
|
+
expect(display.loadIndicatorsCounts).toEqual({
|
|
22
|
+
Artist: 4,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
test('test one level nesting', () => {
|
|
26
|
+
const artistTable = chinookDbInfo_1.chinookDbInfo.tables.find(x => x.pureName == 'Artist');
|
|
27
|
+
const config = (0, PerspectiveConfig_1.createPerspectiveConfig)({ pureName: 'Artist' });
|
|
28
|
+
config.nodes.push((0, PerspectiveConfig_1.createPerspectiveNodeConfig)({ pureName: 'Album' }));
|
|
29
|
+
config.references.push({
|
|
30
|
+
sourceId: config.nodes[0].designerId,
|
|
31
|
+
targetId: config.nodes[1].designerId,
|
|
32
|
+
designerId: '1',
|
|
33
|
+
columns: [{ source: 'ArtistId', target: 'ArtistId' }],
|
|
34
|
+
});
|
|
35
|
+
const configColumns = (0, processPerspectiveDefaultColunns_1.processPerspectiveDefaultColunns)(config, { conid: { db: chinookDbInfo_1.chinookDbInfo } }, 'conid', 'db');
|
|
36
|
+
// const config = createPerspectiveConfig({ pureName: 'Artist' });
|
|
37
|
+
// config.nodes[0].checkedColumns = ['Album'];
|
|
38
|
+
const root = new PerspectiveTreeNode_1.PerspectiveTableNode(artistTable, { conid: { db: chinookDbInfo_1.chinookDbInfo } }, configColumns, null, null, { conid: 'conid', database: 'db' }, null, configColumns.nodes[0].designerId);
|
|
39
|
+
const display = new PerspectiveDisplay_1.PerspectiveDisplay(root, artistDataAlbum_1.default);
|
|
40
|
+
console.log(display.loadIndicatorsCounts);
|
|
41
|
+
// console.log(display.rows);
|
|
42
|
+
expect(display.rows.length).toEqual(6);
|
|
43
|
+
expect(display.rows[0].rowData).toEqual(['AC/DC', 'For Those About To Rock We Salute You']);
|
|
44
|
+
expect(display.rows[0].rowSpans).toEqual([2, 1]);
|
|
45
|
+
expect(display.rows[0].rowCellSkips).toEqual([false, false]);
|
|
46
|
+
expect(display.rows[1].rowData).toEqual([undefined, 'Let There Be Rock']);
|
|
47
|
+
expect(display.rows[1].rowSpans).toEqual([1, 1]);
|
|
48
|
+
expect(display.rows[1].rowCellSkips).toEqual([true, false]);
|
|
49
|
+
expect(display.rows[2].rowData).toEqual(['Accept', 'Balls to the Wall']);
|
|
50
|
+
expect(display.rows[2].rowSpans).toEqual([2, 1]);
|
|
51
|
+
expect(display.rows[2].rowCellSkips).toEqual([false, false]);
|
|
52
|
+
expect(display.rows[5].rowData).toEqual(['Alanis Morissette', 'Jagged Little Pill']);
|
|
53
|
+
expect(display.rows[5].rowSpans).toEqual([1, 1]);
|
|
54
|
+
expect(display.loadIndicatorsCounts).toEqual({
|
|
55
|
+
Artist: 6,
|
|
56
|
+
'Artist.Album': 6,
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
test('test two level nesting', () => {
|
|
60
|
+
const artistTable = chinookDbInfo_1.chinookDbInfo.tables.find(x => x.pureName == 'Artist');
|
|
61
|
+
const config = (0, PerspectiveConfig_1.createPerspectiveConfig)({ pureName: 'Artist' });
|
|
62
|
+
config.nodes.push((0, PerspectiveConfig_1.createPerspectiveNodeConfig)({ pureName: 'Album' }));
|
|
63
|
+
config.nodes.push((0, PerspectiveConfig_1.createPerspectiveNodeConfig)({ pureName: 'Track' }));
|
|
64
|
+
config.references.push({
|
|
65
|
+
sourceId: config.nodes[0].designerId,
|
|
66
|
+
targetId: config.nodes[1].designerId,
|
|
67
|
+
designerId: '1',
|
|
68
|
+
columns: [{ source: 'ArtistId', target: 'ArtistId' }],
|
|
69
|
+
});
|
|
70
|
+
config.references.push({
|
|
71
|
+
sourceId: config.nodes[1].designerId,
|
|
72
|
+
targetId: config.nodes[2].designerId,
|
|
73
|
+
designerId: '2',
|
|
74
|
+
columns: [{ source: 'AlbumId', target: 'AlbumId' }],
|
|
75
|
+
});
|
|
76
|
+
const configColumns = (0, processPerspectiveDefaultColunns_1.processPerspectiveDefaultColunns)(config, { conid: { db: chinookDbInfo_1.chinookDbInfo } }, 'conid', 'db');
|
|
77
|
+
const root = new PerspectiveTreeNode_1.PerspectiveTableNode(artistTable, { conid: { db: chinookDbInfo_1.chinookDbInfo } }, configColumns, null, null, { conid: 'conid', database: 'db' }, null, configColumns.nodes[0].designerId);
|
|
78
|
+
const display = new PerspectiveDisplay_1.PerspectiveDisplay(root, artistDataAlbumTrack_1.default);
|
|
79
|
+
console.log(display.rows);
|
|
80
|
+
expect(display.rows.length).toEqual(8);
|
|
81
|
+
expect(display.rows[0].rowData).toEqual([
|
|
82
|
+
'AC/DC',
|
|
83
|
+
'For Those About To Rock We Salute You',
|
|
84
|
+
'For Those About To Rock (We Salute You)',
|
|
85
|
+
]);
|
|
86
|
+
expect(display.rows[0].rowSpans).toEqual([4, 2, 1]);
|
|
87
|
+
expect(display.rows[0].rowCellSkips).toEqual([false, false, false]);
|
|
88
|
+
expect(display.rows[1].rowData).toEqual([undefined, undefined, 'Put The Finger On You']);
|
|
89
|
+
expect(display.rows[1].rowSpans).toEqual([1, 1, 1]);
|
|
90
|
+
expect(display.rows[1].rowCellSkips).toEqual([true, true, false]);
|
|
91
|
+
expect(display.rows[2].rowData).toEqual([undefined, 'Let There Be Rock', 'Go Down']);
|
|
92
|
+
expect(display.rows[2].rowSpans).toEqual([1, 2, 1]);
|
|
93
|
+
expect(display.rows[2].rowCellSkips).toEqual([true, false, false]);
|
|
94
|
+
});
|
|
@@ -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,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
|
+
];
|