dbgate-datalib 4.7.3-alpha.5 → 4.7.4-alpha.10

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.
@@ -4,5 +4,5 @@ import { GridConfig, GridCache } from './GridConfig';
4
4
  export declare function analyseCollectionDisplayColumns(rows: any, display: any): any[];
5
5
  export declare class CollectionGridDisplay extends GridDisplay {
6
6
  collection: CollectionInfo;
7
- constructor(collection: CollectionInfo, driver: EngineDriver, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, loadedRows: any, changeSet: any);
7
+ constructor(collection: CollectionInfo, driver: EngineDriver, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, loadedRows: any, changeSet: any, readOnly?: boolean);
8
8
  }
@@ -89,7 +89,7 @@ function analyseCollectionDisplayColumns(rows, display) {
89
89
  }
90
90
  exports.analyseCollectionDisplayColumns = analyseCollectionDisplayColumns;
91
91
  class CollectionGridDisplay extends GridDisplay_1.GridDisplay {
92
- constructor(collection, driver, config, setConfig, cache, setCache, loadedRows, changeSet) {
92
+ constructor(collection, driver, config, setConfig, cache, setCache, loadedRows, changeSet, readOnly = false) {
93
93
  super(config, setConfig, cache, setCache, driver);
94
94
  this.collection = collection;
95
95
  const changedDocs = lodash_1.default.compact(changeSet.updates.map(chs => chs.document));
@@ -97,7 +97,7 @@ class CollectionGridDisplay extends GridDisplay_1.GridDisplay {
97
97
  this.columns = analyseCollectionDisplayColumns([...(loadedRows || []), ...changedDocs, ...insertedDocs], this);
98
98
  this.filterable = true;
99
99
  this.sortable = true;
100
- this.editable = true;
100
+ this.editable = !readOnly;
101
101
  this.supportsReload = true;
102
102
  this.isDynamicStructure = true;
103
103
  this.changeSetKeyFields = ['_id'];
@@ -98,15 +98,16 @@ export declare abstract class GridDisplay {
98
98
  processReferences(select: Select, displayedColumnInfo: DisplayedColumnInfo, options: any): void;
99
99
  createSelectBase(name: NamedObjectInfo, columns: ColumnInfo[], options: any): Select;
100
100
  getRowNumberOverSelect(select: Select, offset: number, count: number): Select;
101
- getPageQuery(offset: number, count: number): string;
101
+ getPageQuery(offset: number, count: number): Select;
102
102
  getExportQuery(postprocessSelect?: any): string;
103
+ getExportQueryJson(postprocessSelect?: any): Select;
103
104
  getExportColumnMap(): {
104
105
  dst: string;
105
106
  src: string;
106
107
  ignore: boolean;
107
108
  }[];
108
109
  resizeColumn(uniqueName: string, computedSize: number, diff: number): void;
109
- getCountQuery(): string;
110
+ getCountQuery(): Select;
110
111
  compileFilters(): Condition;
111
112
  switchToFormView(rowData: any): void;
112
113
  switchToJsonView(): void;
@@ -329,7 +329,10 @@ class GridDisplay {
329
329
  const orderColumnName = columns[0].columnName;
330
330
  const select = {
331
331
  commandType: 'select',
332
- from: { name, alias: 'basetbl' },
332
+ from: {
333
+ name: lodash_1.default.pick(name, ['schemaName', 'pureName']),
334
+ alias: 'basetbl',
335
+ },
333
336
  columns: columns.map(col => (Object.assign({ exprType: 'column', alias: col.columnName, source: { alias: 'basetbl' } }, col))),
334
337
  orderBy: [
335
338
  {
@@ -408,8 +411,9 @@ class GridDisplay {
408
411
  select = this.getRowNumberOverSelect(select, offset, count);
409
412
  else if (this.dialect.limitSelect)
410
413
  select.topRecords = count;
411
- const sql = (0, dbgate_sqltree_1.treeToSql)(this.driver, select, dbgate_sqltree_1.dumpSqlSelect);
412
- return sql;
414
+ return select;
415
+ // const sql = treeToSql(this.driver, select, dumpSqlSelect);
416
+ // return sql;
413
417
  }
414
418
  getExportQuery(postprocessSelect = null) {
415
419
  const select = this.createSelect({ isExport: true });
@@ -420,6 +424,14 @@ class GridDisplay {
420
424
  const sql = (0, dbgate_sqltree_1.treeToSql)(this.driver, select, dbgate_sqltree_1.dumpSqlSelect);
421
425
  return sql;
422
426
  }
427
+ getExportQueryJson(postprocessSelect = null) {
428
+ const select = this.createSelect({ isExport: true });
429
+ if (!select)
430
+ return null;
431
+ if (postprocessSelect)
432
+ postprocessSelect(select);
433
+ return select;
434
+ }
423
435
  getExportColumnMap() {
424
436
  var _a, _b;
425
437
  const changesDefined = ((_a = this.config.hiddenColumns) === null || _a === void 0 ? void 0 : _a.length) > 0 || ((_b = this.config.addedColumns) === null || _b === void 0 ? void 0 : _b.length) > 0;
@@ -474,8 +486,9 @@ class GridDisplay {
474
486
  },
475
487
  ];
476
488
  }
477
- const sql = (0, dbgate_sqltree_1.treeToSql)(this.driver, select, dbgate_sqltree_1.dumpSqlSelect);
478
- return sql;
489
+ return select;
490
+ // const sql = treeToSql(this.driver, select, dumpSqlSelect);
491
+ // return sql;
479
492
  }
480
493
  compileFilters() {
481
494
  var _a;
@@ -2,26 +2,27 @@ import { FormViewDisplay } from './FormViewDisplay';
2
2
  import { ChangeCacheFunc, DisplayColumn, ChangeConfigFunc } from './GridDisplay';
3
3
  import { EngineDriver, NamedObjectInfo, DatabaseInfo } from 'dbgate-types';
4
4
  import { GridConfig, GridCache } from './GridConfig';
5
- import { Select, Condition } from 'dbgate-sqltree';
5
+ import { Condition } from 'dbgate-sqltree';
6
6
  import { ChangeSetFieldDefinition, ChangeSetRowDefinition } from './ChangeSet';
7
7
  import { DictionaryDescriptionFunc } from '.';
8
8
  export declare class TableFormViewDisplay extends FormViewDisplay {
9
9
  tableName: NamedObjectInfo;
10
10
  private gridDisplay;
11
- constructor(tableName: NamedObjectInfo, driver: EngineDriver, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, dbinfo: DatabaseInfo, displayOptions: any, serverVersion: any, getDictionaryDescription?: DictionaryDescriptionFunc);
11
+ constructor(tableName: NamedObjectInfo, driver: EngineDriver, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, dbinfo: DatabaseInfo, displayOptions: any, serverVersion: any, getDictionaryDescription?: DictionaryDescriptionFunc, isReadOnly?: boolean);
12
12
  addDisplayColumns(columns: DisplayColumn[]): void;
13
13
  getPrimaryKeyEqualCondition(row?: any): Condition;
14
14
  getPrimaryKeyOperatorCondition(operator: any): Condition;
15
- getSelect(): Select;
16
- getCurrentRowQuery(): string;
17
- getCountSelect(): Select;
18
- getCountQuery(): string;
19
- getBeforeCountQuery(): string;
15
+ getSelect(): import("dbgate-sqltree").Select;
16
+ getCurrentRowQuery(): import("dbgate-sqltree").Select;
17
+ getCountSelect(): import("dbgate-sqltree").Select;
18
+ getCountQuery(): import("dbgate-sqltree").Select;
19
+ getBeforeCountQuery(): import("dbgate-sqltree").Select;
20
20
  navigate(row: any): void;
21
21
  isLoadedCurrentRow(row: any): boolean;
22
- navigateRowQuery(commmand: 'begin' | 'previous' | 'next' | 'end'): string;
22
+ navigateRowQuery(commmand: 'begin' | 'previous' | 'next' | 'end'): import("dbgate-sqltree").Select;
23
23
  getChangeSetRow(row: any): ChangeSetRowDefinition;
24
24
  getChangeSetField(row: any, uniqueName: any): ChangeSetFieldDefinition;
25
25
  toggleExpandedColumn(uniqueName: string, value?: boolean): void;
26
26
  isExpandedColumn(uniqueName: string): boolean;
27
+ get editable(): boolean;
27
28
  }
@@ -9,10 +9,10 @@ const dbgate_sqltree_1 = require("dbgate-sqltree");
9
9
  const TableGridDisplay_1 = require("./TableGridDisplay");
10
10
  const json_stable_stringify_1 = __importDefault(require("json-stable-stringify"));
11
11
  class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
12
- constructor(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription = null) {
12
+ constructor(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription = null, isReadOnly = false) {
13
13
  super(config, setConfig, cache, setCache, driver, dbinfo, serverVersion);
14
14
  this.tableName = tableName;
15
- this.gridDisplay = new TableGridDisplay_1.TableGridDisplay(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription);
15
+ this.gridDisplay = new TableGridDisplay_1.TableGridDisplay(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription, isReadOnly);
16
16
  this.gridDisplay.addAllExpandedColumnsToSelected = true;
17
17
  this.isLoadedCorrectly = this.gridDisplay.isLoadedCorrectly && !!this.driver;
18
18
  this.columns = [];
@@ -125,8 +125,7 @@ class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
125
125
  if (!select)
126
126
  return null;
127
127
  select.where = (0, dbgate_sqltree_1.mergeConditions)(select.where, this.getPrimaryKeyEqualCondition());
128
- const sql = (0, dbgate_sqltree_1.treeToSql)(this.driver, select, dbgate_sqltree_1.dumpSqlSelect);
129
- return sql;
128
+ return select;
130
129
  }
131
130
  getCountSelect() {
132
131
  const select = this.getSelect();
@@ -149,8 +148,7 @@ class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
149
148
  const select = this.getCountSelect();
150
149
  if (!select)
151
150
  return null;
152
- const sql = (0, dbgate_sqltree_1.treeToSql)(this.driver, select, dbgate_sqltree_1.dumpSqlSelect);
153
- return sql;
151
+ return select;
154
152
  }
155
153
  getBeforeCountQuery() {
156
154
  if (!this.driver)
@@ -159,8 +157,7 @@ class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
159
157
  if (!select)
160
158
  return null;
161
159
  select.where = (0, dbgate_sqltree_1.mergeConditions)(select.where, this.getPrimaryKeyOperatorCondition('<'));
162
- const sql = (0, dbgate_sqltree_1.treeToSql)(this.driver, select, dbgate_sqltree_1.dumpSqlSelect);
163
- return sql;
160
+ return select;
164
161
  }
165
162
  navigate(row) {
166
163
  const formViewKey = this.extractKey(row);
@@ -203,8 +200,7 @@ class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
203
200
  select.where = (0, dbgate_sqltree_1.mergeConditions)(select.where, this.getPrimaryKeyOperatorCondition('>'));
204
201
  break;
205
202
  }
206
- const sql = (0, dbgate_sqltree_1.treeToSql)(this.driver, select, dbgate_sqltree_1.dumpSqlSelect);
207
- return sql;
203
+ return select;
208
204
  }
209
205
  getChangeSetRow(row) {
210
206
  if (!this.baseTable)
@@ -232,5 +228,8 @@ class TableFormViewDisplay extends FormViewDisplay_1.FormViewDisplay {
232
228
  isExpandedColumn(uniqueName) {
233
229
  return this.gridDisplay.isExpandedColumn(uniqueName);
234
230
  }
231
+ get editable() {
232
+ return this.gridDisplay.editable;
233
+ }
235
234
  }
236
235
  exports.TableFormViewDisplay = TableFormViewDisplay;
@@ -15,7 +15,7 @@ export declare class TableGridDisplay extends GridDisplay {
15
15
  table: TableInfo;
16
16
  addAllExpandedColumnsToSelected: boolean;
17
17
  hintBaseColumns: DisplayColumn[];
18
- constructor(tableName: NamedObjectInfo, driver: EngineDriver, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, dbinfo: DatabaseInfo, displayOptions: any, serverVersion: any, getDictionaryDescription?: DictionaryDescriptionFunc);
18
+ constructor(tableName: NamedObjectInfo, driver: EngineDriver, config: GridConfig, setConfig: ChangeConfigFunc, cache: GridCache, setCache: ChangeCacheFunc, dbinfo: DatabaseInfo, displayOptions: any, serverVersion: any, getDictionaryDescription?: DictionaryDescriptionFunc, isReadOnly?: boolean);
19
19
  findTable({ schemaName, pureName }: {
20
20
  schemaName?: any;
21
21
  pureName: any;
@@ -4,7 +4,7 @@ exports.TableGridDisplay = void 0;
4
4
  const dbgate_tools_1 = require("dbgate-tools");
5
5
  const GridDisplay_1 = require("./GridDisplay");
6
6
  class TableGridDisplay extends GridDisplay_1.GridDisplay {
7
- constructor(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription = null) {
7
+ constructor(tableName, driver, config, setConfig, cache, setCache, dbinfo, displayOptions, serverVersion, getDictionaryDescription = null, isReadOnly = false) {
8
8
  super(config, setConfig, cache, setCache, driver, dbinfo, serverVersion);
9
9
  this.tableName = tableName;
10
10
  this.displayOptions = displayOptions;
@@ -23,7 +23,7 @@ class TableGridDisplay extends GridDisplay_1.GridDisplay {
23
23
  this.filterable = true;
24
24
  this.sortable = true;
25
25
  this.groupable = true;
26
- this.editable = true;
26
+ this.editable = !isReadOnly;
27
27
  this.supportsReload = true;
28
28
  this.baseTable = this.table;
29
29
  if (this.table && this.table.columns) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.7.3-alpha.5",
2
+ "version": "4.7.4-alpha.10",
3
3
  "name": "dbgate-datalib",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
@@ -11,11 +11,11 @@
11
11
  "lib"
12
12
  ],
13
13
  "dependencies": {
14
- "dbgate-sqltree": "^4.7.3-alpha.5",
15
- "dbgate-filterparser": "^4.7.3-alpha.5"
14
+ "dbgate-sqltree": "^4.7.4-alpha.10",
15
+ "dbgate-filterparser": "^4.7.4-alpha.10"
16
16
  },
17
17
  "devDependencies": {
18
- "dbgate-types": "^4.7.3-alpha.5",
18
+ "dbgate-types": "^4.7.4-alpha.10",
19
19
  "@types/node": "^13.7.0",
20
20
  "typescript": "^4.4.3"
21
21
  }