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
|
@@ -14,8 +14,8 @@ export declare class FreeTableGridDisplay extends GridDisplay {
|
|
|
14
14
|
uniquePath: string[];
|
|
15
15
|
pairingId?: string;
|
|
16
16
|
columnName: string;
|
|
17
|
-
notNull
|
|
18
|
-
autoIncrement
|
|
17
|
+
notNull?: boolean;
|
|
18
|
+
autoIncrement?: boolean;
|
|
19
19
|
dataType: string;
|
|
20
20
|
precision?: number;
|
|
21
21
|
scale?: number;
|
|
@@ -28,6 +28,8 @@ export declare class FreeTableGridDisplay extends GridDisplay {
|
|
|
28
28
|
columnComment?: string;
|
|
29
29
|
isUnsigned?: boolean;
|
|
30
30
|
isZerofill?: boolean;
|
|
31
|
+
contentHash?: string;
|
|
32
|
+
engine?: string;
|
|
31
33
|
}[];
|
|
32
34
|
getDisplayColumn(col: ColumnInfo): {
|
|
33
35
|
pureName: string;
|
|
@@ -37,8 +39,8 @@ export declare class FreeTableGridDisplay extends GridDisplay {
|
|
|
37
39
|
uniquePath: string[];
|
|
38
40
|
pairingId?: string;
|
|
39
41
|
columnName: string;
|
|
40
|
-
notNull
|
|
41
|
-
autoIncrement
|
|
42
|
+
notNull?: boolean;
|
|
43
|
+
autoIncrement?: boolean;
|
|
42
44
|
dataType: string;
|
|
43
45
|
precision?: number;
|
|
44
46
|
scale?: number;
|
|
@@ -51,5 +53,7 @@ export declare class FreeTableGridDisplay extends GridDisplay {
|
|
|
51
53
|
columnComment?: string;
|
|
52
54
|
isUnsigned?: boolean;
|
|
53
55
|
isZerofill?: boolean;
|
|
56
|
+
contentHash?: string;
|
|
57
|
+
engine?: string;
|
|
54
58
|
};
|
|
55
59
|
}
|
package/lib/GridDisplay.d.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { PerspectiveDataLoadProps } from './PerspectiveDataProvider';
|
|
2
|
+
export declare class PerspectiveBindingGroup {
|
|
3
|
+
table: PerspectiveCacheTable;
|
|
4
|
+
constructor(table: PerspectiveCacheTable);
|
|
5
|
+
groupSize?: number;
|
|
6
|
+
loadedAll: boolean;
|
|
7
|
+
loadedRows: any[];
|
|
8
|
+
bindingValues: any[];
|
|
9
|
+
matchRow(row: any): boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class PerspectiveCacheTable {
|
|
12
|
+
cache: PerspectiveCache;
|
|
13
|
+
constructor(props: PerspectiveDataLoadProps, cache: PerspectiveCache);
|
|
14
|
+
schemaName: string;
|
|
15
|
+
pureName: string;
|
|
16
|
+
bindingColumns?: string[];
|
|
17
|
+
dataColumns: string[];
|
|
18
|
+
loadedAll: boolean;
|
|
19
|
+
loadedRows: any[];
|
|
20
|
+
bindingGroups: {
|
|
21
|
+
[bindingKey: string]: PerspectiveBindingGroup;
|
|
22
|
+
};
|
|
23
|
+
get loadedCount(): number;
|
|
24
|
+
getRowsResult(props: PerspectiveDataLoadProps): {
|
|
25
|
+
rows: any[];
|
|
26
|
+
incomplete: boolean;
|
|
27
|
+
};
|
|
28
|
+
getBindingGroup(groupValues: any[]): PerspectiveBindingGroup;
|
|
29
|
+
getUncachedBindingGroups(props: PerspectiveDataLoadProps): any[][];
|
|
30
|
+
storeGroupSize(props: PerspectiveDataLoadProps, bindingValues: any[], count: number): void;
|
|
31
|
+
}
|
|
32
|
+
export declare class PerspectiveCache {
|
|
33
|
+
constructor();
|
|
34
|
+
tables: {
|
|
35
|
+
[tableKey: string]: PerspectiveCacheTable;
|
|
36
|
+
};
|
|
37
|
+
getTableCache(props: PerspectiveDataLoadProps): PerspectiveCacheTable;
|
|
38
|
+
clear(): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
exports.PerspectiveCache = exports.PerspectiveCacheTable = exports.PerspectiveBindingGroup = void 0;
|
|
7
|
+
const pick_1 = __importDefault(require("lodash/pick"));
|
|
8
|
+
const zip_1 = __importDefault(require("lodash/zip"));
|
|
9
|
+
const difference_1 = __importDefault(require("lodash/difference"));
|
|
10
|
+
const debug_1 = __importDefault(require("debug"));
|
|
11
|
+
const json_stable_stringify_1 = __importDefault(require("json-stable-stringify"));
|
|
12
|
+
const dbg = (0, debug_1.default)('dbgate:PerspectiveCache');
|
|
13
|
+
class PerspectiveBindingGroup {
|
|
14
|
+
constructor(table) {
|
|
15
|
+
this.table = table;
|
|
16
|
+
this.loadedRows = [];
|
|
17
|
+
}
|
|
18
|
+
matchRow(row) {
|
|
19
|
+
return this.table.bindingColumns.every((column, index) => row[column] == this.bindingValues[index]);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.PerspectiveBindingGroup = PerspectiveBindingGroup;
|
|
23
|
+
class PerspectiveCacheTable {
|
|
24
|
+
constructor(props, cache) {
|
|
25
|
+
this.cache = cache;
|
|
26
|
+
this.loadedRows = [];
|
|
27
|
+
this.bindingGroups = {};
|
|
28
|
+
this.schemaName = props.schemaName;
|
|
29
|
+
this.pureName = props.pureName;
|
|
30
|
+
this.bindingColumns = props.bindingColumns;
|
|
31
|
+
this.dataColumns = props.dataColumns;
|
|
32
|
+
this.loadedAll = false;
|
|
33
|
+
}
|
|
34
|
+
get loadedCount() {
|
|
35
|
+
return this.loadedRows.length;
|
|
36
|
+
}
|
|
37
|
+
getRowsResult(props) {
|
|
38
|
+
return {
|
|
39
|
+
rows: this.loadedRows.slice(0, props.topCount),
|
|
40
|
+
incomplete: props.topCount < this.loadedCount || !this.loadedAll,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
getBindingGroup(groupValues) {
|
|
44
|
+
const key = (0, json_stable_stringify_1.default)(groupValues);
|
|
45
|
+
return this.bindingGroups[key];
|
|
46
|
+
}
|
|
47
|
+
getUncachedBindingGroups(props) {
|
|
48
|
+
const uncached = [];
|
|
49
|
+
for (const group of props.bindingValues) {
|
|
50
|
+
const key = (0, json_stable_stringify_1.default)(group);
|
|
51
|
+
const item = this.bindingGroups[key];
|
|
52
|
+
if (!item) {
|
|
53
|
+
uncached.push(group);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return uncached;
|
|
57
|
+
}
|
|
58
|
+
storeGroupSize(props, bindingValues, count) {
|
|
59
|
+
const originalBindingValue = props.bindingValues.find(v => (0, zip_1.default)(v, bindingValues).every(([x, y]) => x == y));
|
|
60
|
+
if (originalBindingValue) {
|
|
61
|
+
const key = (0, json_stable_stringify_1.default)(originalBindingValue);
|
|
62
|
+
// console.log('SET SIZE', originalBindingValue, bindingValues, key, count);
|
|
63
|
+
const group = new PerspectiveBindingGroup(this);
|
|
64
|
+
group.bindingValues = bindingValues;
|
|
65
|
+
group.groupSize = count;
|
|
66
|
+
this.bindingGroups[key] = group;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
dbg('Group not found', bindingValues);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.PerspectiveCacheTable = PerspectiveCacheTable;
|
|
74
|
+
class PerspectiveCache {
|
|
75
|
+
constructor() {
|
|
76
|
+
this.tables = {};
|
|
77
|
+
}
|
|
78
|
+
getTableCache(props) {
|
|
79
|
+
const tableKey = (0, json_stable_stringify_1.default)((0, pick_1.default)(props, ['schemaName', 'pureName', 'bindingColumns', 'databaseConfig', 'orderBy', 'condition']));
|
|
80
|
+
let res = this.tables[tableKey];
|
|
81
|
+
if (res && (0, difference_1.default)(props.dataColumns, res.dataColumns).length > 0) {
|
|
82
|
+
dbg('Delete cache because incomplete columns', props.pureName, res.dataColumns);
|
|
83
|
+
// we have incomplete cache
|
|
84
|
+
delete this.tables[tableKey];
|
|
85
|
+
res = null;
|
|
86
|
+
}
|
|
87
|
+
if (!res) {
|
|
88
|
+
res = new PerspectiveCacheTable(props, this);
|
|
89
|
+
this.tables[tableKey] = res;
|
|
90
|
+
return res;
|
|
91
|
+
}
|
|
92
|
+
// cache could be used
|
|
93
|
+
return res;
|
|
94
|
+
}
|
|
95
|
+
clear() {
|
|
96
|
+
this.tables = {};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.PerspectiveCache = PerspectiveCache;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { DatabaseInfo, ForeignKeyInfo } from 'dbgate-types';
|
|
2
|
+
export interface PerspectiveCustomJoinConfig {
|
|
3
|
+
refNodeDesignerId: string;
|
|
4
|
+
referenceDesignerId: string;
|
|
5
|
+
joinName: string;
|
|
6
|
+
baseDesignerId: string;
|
|
7
|
+
conid?: string;
|
|
8
|
+
database?: string;
|
|
9
|
+
refSchemaName?: string;
|
|
10
|
+
refTableName: string;
|
|
11
|
+
columns: {
|
|
12
|
+
baseColumnName: string;
|
|
13
|
+
refColumnName: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
export interface PerspectiveFilterColumnInfo {
|
|
17
|
+
columnName: string;
|
|
18
|
+
filterType: string;
|
|
19
|
+
pureName: string;
|
|
20
|
+
schemaName: string;
|
|
21
|
+
foreignKey: ForeignKeyInfo;
|
|
22
|
+
}
|
|
23
|
+
export interface PerspectiveNodeConfig {
|
|
24
|
+
designerId: string;
|
|
25
|
+
schemaName?: string;
|
|
26
|
+
pureName: string;
|
|
27
|
+
defaultColumnsProcessed?: boolean;
|
|
28
|
+
alias?: string;
|
|
29
|
+
conid?: string;
|
|
30
|
+
database?: string;
|
|
31
|
+
isParentFilter?: boolean;
|
|
32
|
+
expandedColumns: string[];
|
|
33
|
+
checkedColumns: string[];
|
|
34
|
+
sort: {
|
|
35
|
+
columnName: string;
|
|
36
|
+
order: 'ASC' | 'DESC';
|
|
37
|
+
}[];
|
|
38
|
+
filters: {
|
|
39
|
+
[uniqueName: string]: string;
|
|
40
|
+
};
|
|
41
|
+
isAutoGenerated?: true | undefined;
|
|
42
|
+
isNodeChecked?: boolean;
|
|
43
|
+
position?: {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface PerspectiveReferenceConfig {
|
|
49
|
+
designerId: string;
|
|
50
|
+
sourceId: string;
|
|
51
|
+
targetId: string;
|
|
52
|
+
columns: {
|
|
53
|
+
source: string;
|
|
54
|
+
target: string;
|
|
55
|
+
}[];
|
|
56
|
+
isAutoGenerated?: true | undefined;
|
|
57
|
+
}
|
|
58
|
+
export interface PerspectiveConfig {
|
|
59
|
+
rootDesignerId: string;
|
|
60
|
+
isArranged: boolean;
|
|
61
|
+
nodes: PerspectiveNodeConfig[];
|
|
62
|
+
references: PerspectiveReferenceConfig[];
|
|
63
|
+
}
|
|
64
|
+
export declare function createPerspectiveNodeConfig(name: {
|
|
65
|
+
schemaName?: string;
|
|
66
|
+
pureName: string;
|
|
67
|
+
}): PerspectiveNodeConfig;
|
|
68
|
+
export declare function createPerspectiveConfig(rootObject?: {
|
|
69
|
+
schemaName?: string;
|
|
70
|
+
pureName: string;
|
|
71
|
+
}): PerspectiveConfig;
|
|
72
|
+
export declare type ChangePerspectiveConfigFunc = (changeFunc: (config: PerspectiveConfig) => PerspectiveConfig, reload?: boolean) => void;
|
|
73
|
+
export declare function extractPerspectiveDatabases({ conid, database }: {
|
|
74
|
+
conid: any;
|
|
75
|
+
database: any;
|
|
76
|
+
}, cfg: PerspectiveConfig): {
|
|
77
|
+
conid: string;
|
|
78
|
+
database: string;
|
|
79
|
+
}[];
|
|
80
|
+
export interface MultipleDatabaseInfo {
|
|
81
|
+
[conid: string]: {
|
|
82
|
+
[database: string]: DatabaseInfo;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export declare function switchPerspectiveReferenceDirection(ref: PerspectiveReferenceConfig): PerspectiveReferenceConfig;
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
exports.switchPerspectiveReferenceDirection = exports.extractPerspectiveDatabases = exports.createPerspectiveConfig = exports.createPerspectiveNodeConfig = void 0;
|
|
7
|
+
const v1_1 = __importDefault(require("uuid/v1"));
|
|
8
|
+
function createPerspectiveNodeConfig(name) {
|
|
9
|
+
const node = Object.assign(Object.assign({}, name), { designerId: (0, v1_1.default)(), expandedColumns: [], checkedColumns: [], sort: [], filters: {}, isNodeChecked: true });
|
|
10
|
+
return node;
|
|
11
|
+
}
|
|
12
|
+
exports.createPerspectiveNodeConfig = createPerspectiveNodeConfig;
|
|
13
|
+
function createPerspectiveConfig(rootObject) {
|
|
14
|
+
if (!rootObject) {
|
|
15
|
+
return {
|
|
16
|
+
nodes: [],
|
|
17
|
+
references: [],
|
|
18
|
+
isArranged: true,
|
|
19
|
+
rootDesignerId: null,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const rootNode = createPerspectiveNodeConfig(rootObject);
|
|
23
|
+
return {
|
|
24
|
+
nodes: [rootNode],
|
|
25
|
+
references: [],
|
|
26
|
+
rootDesignerId: rootNode.designerId,
|
|
27
|
+
isArranged: true,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.createPerspectiveConfig = createPerspectiveConfig;
|
|
31
|
+
function extractPerspectiveDatabases({ conid, database }, cfg) {
|
|
32
|
+
const res = [];
|
|
33
|
+
res.push({ conid, database });
|
|
34
|
+
function add(conid, database) {
|
|
35
|
+
if (res.find(x => x.conid == conid && x.database == database))
|
|
36
|
+
return;
|
|
37
|
+
res.push({ conid, database });
|
|
38
|
+
}
|
|
39
|
+
for (const node of cfg.nodes) {
|
|
40
|
+
add(node.conid || conid, node.database || database);
|
|
41
|
+
}
|
|
42
|
+
return res;
|
|
43
|
+
}
|
|
44
|
+
exports.extractPerspectiveDatabases = extractPerspectiveDatabases;
|
|
45
|
+
function switchPerspectiveReferenceDirection(ref) {
|
|
46
|
+
return {
|
|
47
|
+
designerId: ref.designerId,
|
|
48
|
+
sourceId: ref.targetId,
|
|
49
|
+
targetId: ref.sourceId,
|
|
50
|
+
isAutoGenerated: ref.isAutoGenerated,
|
|
51
|
+
columns: ref.columns.map(x => ({ source: x.target, target: x.source })),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
exports.switchPerspectiveReferenceDirection = switchPerspectiveReferenceDirection;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Condition } from 'dbgate-sqltree';
|
|
2
|
+
import { PerspectiveDataLoadProps } from './PerspectiveDataProvider';
|
|
3
|
+
export declare class PerspectiveDataLoader {
|
|
4
|
+
apiCall: any;
|
|
5
|
+
constructor(apiCall: any);
|
|
6
|
+
buildCondition(props: PerspectiveDataLoadProps): Condition;
|
|
7
|
+
loadGrouping(props: PerspectiveDataLoadProps): Promise<any>;
|
|
8
|
+
loadData(props: PerspectiveDataLoadProps): Promise<any>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PerspectiveDataLoader = void 0;
|
|
16
|
+
const debug_1 = __importDefault(require("debug"));
|
|
17
|
+
const dbg = (0, debug_1.default)('dbgate:PerspectiveDataLoader');
|
|
18
|
+
class PerspectiveDataLoader {
|
|
19
|
+
constructor(apiCall) {
|
|
20
|
+
this.apiCall = apiCall;
|
|
21
|
+
}
|
|
22
|
+
buildCondition(props) {
|
|
23
|
+
const { schemaName, pureName, bindingColumns, bindingValues, dataColumns, orderBy, condition } = props;
|
|
24
|
+
const conditions = [];
|
|
25
|
+
if (condition) {
|
|
26
|
+
conditions.push(condition);
|
|
27
|
+
}
|
|
28
|
+
if ((bindingColumns === null || bindingColumns === void 0 ? void 0 : bindingColumns.length) == 1) {
|
|
29
|
+
conditions.push({
|
|
30
|
+
conditionType: 'in',
|
|
31
|
+
expr: {
|
|
32
|
+
exprType: 'column',
|
|
33
|
+
columnName: bindingColumns[0],
|
|
34
|
+
source: {
|
|
35
|
+
name: { schemaName, pureName },
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
values: bindingValues.map(x => x[0]),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return conditions.length > 0
|
|
42
|
+
? {
|
|
43
|
+
conditionType: 'and',
|
|
44
|
+
conditions,
|
|
45
|
+
}
|
|
46
|
+
: null;
|
|
47
|
+
}
|
|
48
|
+
loadGrouping(props) {
|
|
49
|
+
var _a;
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const { schemaName, pureName, bindingColumns, bindingValues, dataColumns } = props;
|
|
52
|
+
const bindingColumnExpressions = bindingColumns.map(columnName => ({
|
|
53
|
+
exprType: 'column',
|
|
54
|
+
columnName,
|
|
55
|
+
source: {
|
|
56
|
+
name: { schemaName, pureName },
|
|
57
|
+
},
|
|
58
|
+
}));
|
|
59
|
+
const select = {
|
|
60
|
+
commandType: 'select',
|
|
61
|
+
from: {
|
|
62
|
+
name: { schemaName, pureName },
|
|
63
|
+
},
|
|
64
|
+
columns: [
|
|
65
|
+
{
|
|
66
|
+
exprType: 'call',
|
|
67
|
+
func: 'COUNT',
|
|
68
|
+
args: [
|
|
69
|
+
{
|
|
70
|
+
exprType: 'raw',
|
|
71
|
+
sql: '*',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
alias: '_perspective_group_size_',
|
|
75
|
+
},
|
|
76
|
+
...bindingColumnExpressions,
|
|
77
|
+
],
|
|
78
|
+
where: this.buildCondition(props),
|
|
79
|
+
};
|
|
80
|
+
select.groupBy = bindingColumnExpressions;
|
|
81
|
+
if (dbg === null || dbg === void 0 ? void 0 : dbg.enabled) {
|
|
82
|
+
dbg(`LOAD COUNTS, table=${props.pureName}, columns=${(_a = props.dataColumns) === null || _a === void 0 ? void 0 : _a.join(',')}`);
|
|
83
|
+
}
|
|
84
|
+
const response = yield this.apiCall('database-connections/sql-select', {
|
|
85
|
+
conid: props.databaseConfig.conid,
|
|
86
|
+
database: props.databaseConfig.database,
|
|
87
|
+
select,
|
|
88
|
+
});
|
|
89
|
+
if (response.errorMessage)
|
|
90
|
+
return response;
|
|
91
|
+
return response.rows.map(row => (Object.assign(Object.assign({}, row), { _perspective_group_size_: parseInt(row._perspective_group_size_) })));
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
loadData(props) {
|
|
95
|
+
var _a, _b, _c;
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const { schemaName, pureName, bindingColumns, bindingValues, dataColumns, orderBy, condition } = props;
|
|
98
|
+
if ((dataColumns === null || dataColumns === void 0 ? void 0 : dataColumns.length) == 0) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
const select = {
|
|
102
|
+
commandType: 'select',
|
|
103
|
+
from: {
|
|
104
|
+
name: { schemaName, pureName },
|
|
105
|
+
},
|
|
106
|
+
columns: dataColumns === null || dataColumns === void 0 ? void 0 : dataColumns.map(columnName => ({
|
|
107
|
+
exprType: 'column',
|
|
108
|
+
columnName,
|
|
109
|
+
source: {
|
|
110
|
+
name: { schemaName, pureName },
|
|
111
|
+
},
|
|
112
|
+
})),
|
|
113
|
+
selectAll: !dataColumns,
|
|
114
|
+
orderBy: orderBy === null || orderBy === void 0 ? void 0 : orderBy.map(({ columnName, order }) => ({
|
|
115
|
+
exprType: 'column',
|
|
116
|
+
columnName,
|
|
117
|
+
direction: order,
|
|
118
|
+
source: {
|
|
119
|
+
name: { schemaName, pureName },
|
|
120
|
+
},
|
|
121
|
+
})),
|
|
122
|
+
range: props.range,
|
|
123
|
+
where: this.buildCondition(props),
|
|
124
|
+
};
|
|
125
|
+
if (dbg === null || dbg === void 0 ? void 0 : dbg.enabled) {
|
|
126
|
+
dbg(`LOAD DATA, table=${props.pureName}, columns=${(_a = props.dataColumns) === null || _a === void 0 ? void 0 : _a.join(',')}, range=${(_b = props.range) === null || _b === void 0 ? void 0 : _b.offset},${(_c = props.range) === null || _c === void 0 ? void 0 : _c.limit}`);
|
|
127
|
+
}
|
|
128
|
+
const response = yield this.apiCall('database-connections/sql-select', {
|
|
129
|
+
conid: props.databaseConfig.conid,
|
|
130
|
+
database: props.databaseConfig.database,
|
|
131
|
+
select,
|
|
132
|
+
});
|
|
133
|
+
if (response.errorMessage)
|
|
134
|
+
return response;
|
|
135
|
+
return response.rows;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.PerspectiveDataLoader = PerspectiveDataLoader;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Condition } from 'dbgate-sqltree';
|
|
2
|
+
import { RangeDefinition } from 'dbgate-types';
|
|
3
|
+
import { PerspectiveCache } from './PerspectiveCache';
|
|
4
|
+
import { PerspectiveDataLoader } from './PerspectiveDataLoader';
|
|
5
|
+
export declare const PERSPECTIVE_PAGE_SIZE = 100;
|
|
6
|
+
export interface PerspectiveDatabaseConfig {
|
|
7
|
+
conid: string;
|
|
8
|
+
database: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PerspectiveDataLoadProps {
|
|
11
|
+
databaseConfig: PerspectiveDatabaseConfig;
|
|
12
|
+
schemaName: string;
|
|
13
|
+
pureName: string;
|
|
14
|
+
dataColumns: string[];
|
|
15
|
+
orderBy: {
|
|
16
|
+
columnName: string;
|
|
17
|
+
order: 'ASC' | 'DESC';
|
|
18
|
+
}[];
|
|
19
|
+
bindingColumns?: string[];
|
|
20
|
+
bindingValues?: any[][];
|
|
21
|
+
range?: RangeDefinition;
|
|
22
|
+
topCount?: number;
|
|
23
|
+
condition?: Condition;
|
|
24
|
+
}
|
|
25
|
+
export declare class PerspectiveDataProvider {
|
|
26
|
+
cache: PerspectiveCache;
|
|
27
|
+
loader: PerspectiveDataLoader;
|
|
28
|
+
constructor(cache: PerspectiveCache, loader: PerspectiveDataLoader);
|
|
29
|
+
loadData(props: PerspectiveDataLoadProps): Promise<{
|
|
30
|
+
rows: any[];
|
|
31
|
+
incomplete: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
loadDataNested(props: PerspectiveDataLoadProps): Promise<{
|
|
34
|
+
rows: any[];
|
|
35
|
+
incomplete: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
loadNextGroup(props: PerspectiveDataLoadProps, groupIndex: number): Promise<void>;
|
|
38
|
+
loadDataFlat(props: PerspectiveDataLoadProps): Promise<{
|
|
39
|
+
rows: any[];
|
|
40
|
+
incomplete: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
}
|