dbgate-datalib 5.1.1 → 5.1.3

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.
@@ -20,6 +20,7 @@ export declare class PerspectiveCacheTable {
20
20
  bindingGroups: {
21
21
  [bindingKey: string]: PerspectiveBindingGroup;
22
22
  };
23
+ allRowCount: number;
23
24
  get loadedCount(): number;
24
25
  getRowsResult(props: PerspectiveDataLoadProps): {
25
26
  rows: any[];
@@ -25,6 +25,7 @@ class PerspectiveCacheTable {
25
25
  this.cache = cache;
26
26
  this.loadedRows = [];
27
27
  this.bindingGroups = {};
28
+ this.allRowCount = null;
28
29
  this.schemaName = props.schemaName;
29
30
  this.pureName = props.pureName;
30
31
  this.bindingColumns = props.bindingColumns;
@@ -31,6 +31,7 @@ export interface PerspectiveNodeConfig {
31
31
  isParentFilter?: boolean;
32
32
  expandedColumns: string[];
33
33
  checkedColumns: string[];
34
+ columnDisplays: {};
34
35
  sort: {
35
36
  columnName: string;
36
37
  order: 'ASC' | 'DESC';
@@ -6,7 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.switchPerspectiveReferenceDirection = exports.extractPerspectiveDatabases = exports.createPerspectiveConfig = exports.createPerspectiveNodeConfig = void 0;
7
7
  const v1_1 = __importDefault(require("uuid/v1"));
8
8
  function createPerspectiveNodeConfig(name) {
9
- const node = Object.assign(Object.assign({}, name), { designerId: (0, v1_1.default)(), expandedColumns: [], checkedColumns: [], sort: [], filters: {}, isNodeChecked: true });
9
+ const node = {
10
+ pureName: name.pureName,
11
+ schemaName: name.schemaName,
12
+ designerId: (0, v1_1.default)(),
13
+ expandedColumns: [],
14
+ checkedColumns: [],
15
+ columnDisplays: {},
16
+ sort: [],
17
+ filters: {},
18
+ isNodeChecked: true,
19
+ };
10
20
  return node;
11
21
  }
12
22
  exports.createPerspectiveNodeConfig = createPerspectiveNodeConfig;
@@ -6,4 +6,5 @@ export declare class PerspectiveDataLoader {
6
6
  buildCondition(props: PerspectiveDataLoadProps): Condition;
7
7
  loadGrouping(props: PerspectiveDataLoadProps): Promise<any>;
8
8
  loadData(props: PerspectiveDataLoadProps): Promise<any>;
9
+ loadRowCount(props: PerspectiveDataLoadProps): Promise<any>;
9
10
  }
@@ -135,5 +135,32 @@ class PerspectiveDataLoader {
135
135
  return response.rows;
136
136
  });
137
137
  }
138
+ loadRowCount(props) {
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ const { schemaName, pureName, bindingColumns, bindingValues, dataColumns, orderBy, condition } = props;
141
+ const select = {
142
+ commandType: 'select',
143
+ from: {
144
+ name: { schemaName, pureName },
145
+ },
146
+ columns: [
147
+ {
148
+ exprType: 'raw',
149
+ sql: 'COUNT(*)',
150
+ alias: 'count',
151
+ },
152
+ ],
153
+ where: this.buildCondition(props),
154
+ };
155
+ const response = yield this.apiCall('database-connections/sql-select', {
156
+ conid: props.databaseConfig.conid,
157
+ database: props.databaseConfig.database,
158
+ select,
159
+ });
160
+ if (response.errorMessage)
161
+ return response;
162
+ return response.rows[0];
163
+ });
164
+ }
138
165
  }
139
166
  exports.PerspectiveDataLoader = PerspectiveDataLoader;
@@ -39,4 +39,5 @@ export declare class PerspectiveDataProvider {
39
39
  rows: any[];
40
40
  incomplete: boolean;
41
41
  }>;
42
+ loadRowCount(props: PerspectiveDataLoadProps): Promise<number>;
42
43
  }
@@ -177,5 +177,19 @@ class PerspectiveDataProvider {
177
177
  return tableCache.getRowsResult(props);
178
178
  });
179
179
  }
180
+ loadRowCount(props) {
181
+ return __awaiter(this, void 0, void 0, function* () {
182
+ const tableCache = this.cache.getTableCache(props);
183
+ if (tableCache.allRowCount != null) {
184
+ return tableCache.allRowCount;
185
+ }
186
+ const result = yield this.loader.loadRowCount(Object.assign({}, props));
187
+ if (result.errorMessage) {
188
+ throw new Error(result.errorMessage);
189
+ }
190
+ tableCache.allRowCount = parseInt(result.count);
191
+ return tableCache.allRowCount;
192
+ });
193
+ }
180
194
  }
181
195
  exports.PerspectiveDataProvider = PerspectiveDataProvider;
@@ -3,6 +3,7 @@ export declare class PerspectiveDisplayColumn {
3
3
  display: PerspectiveDisplay;
4
4
  title: string;
5
5
  dataField: string;
6
+ displayType: string;
6
7
  parentNodes: PerspectiveTreeNode[];
7
8
  colSpanAtLevel: {};
8
9
  columnIndex: number;
@@ -105,6 +105,7 @@ class PerspectiveDisplay {
105
105
  }
106
106
  }
107
107
  processColumn(node, parentNodes) {
108
+ var _a, _b;
108
109
  if (node.isCheckedColumn) {
109
110
  const column = new PerspectiveDisplayColumn(this);
110
111
  column.title = node.columnTitle;
@@ -113,6 +114,7 @@ class PerspectiveDisplay {
113
114
  column.display = this;
114
115
  column.columnIndex = this.columns.length;
115
116
  column.dataNode = node;
117
+ column.displayType = (_b = (_a = node.parentNodeConfig) === null || _a === void 0 ? void 0 : _a.columnDisplays) === null || _b === void 0 ? void 0 : _b[node.columnName];
116
118
  this.columns.push(column);
117
119
  }
118
120
  if (node.isExpandable && node.isCheckedNode) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.1.1",
2
+ "version": "5.1.3",
3
3
  "name": "dbgate-datalib",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
@@ -13,12 +13,12 @@
13
13
  "lib"
14
14
  ],
15
15
  "dependencies": {
16
- "dbgate-sqltree": "^5.1.1",
17
- "dbgate-tools": "^5.1.1",
18
- "dbgate-filterparser": "^5.1.1"
16
+ "dbgate-sqltree": "^5.1.3",
17
+ "dbgate-tools": "^5.1.3",
18
+ "dbgate-filterparser": "^5.1.3"
19
19
  },
20
20
  "devDependencies": {
21
- "dbgate-types": "^5.1.1",
21
+ "dbgate-types": "^5.1.3",
22
22
  "@types/node": "^13.7.0",
23
23
  "jest": "^28.1.3",
24
24
  "ts-jest": "^28.0.7",