@genesislcap/grid-pro 14.12.2 → 14.12.3-alpha-964c9f1.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.
@@ -346,17 +346,20 @@ export declare class GridProGenesisDatasource extends GridProGenesisDatasource_b
346
346
  isSnapshot: boolean;
347
347
  maxRows: number;
348
348
  maxView: number;
349
+ pollingInterval: number;
349
350
  movingView: boolean;
350
351
  orderBy: string;
351
352
  request: any;
352
353
  resourceName: string;
353
354
  resourceNameChanged(oldValue: string, newValue: string): void;
354
355
  reverse: boolean;
355
- rowId: string;
356
+ rowId: any;
357
+ datasourceKey: string;
356
358
  restartOnReconnection: boolean;
357
359
  private dataSub;
358
360
  private updateSub;
359
361
  private connectionSub;
362
+ private isRequestServer;
360
363
  private requiresFullRowDataAndColDefs;
361
364
  private dataSubWasLoggedOff;
362
365
  private rows;
@@ -368,7 +371,8 @@ export declare class GridProGenesisDatasource extends GridProGenesisDatasource_b
368
371
  disconnectedCallback(): void;
369
372
  deepClone(): Node;
370
373
  private get agGrid();
371
- init(): void;
374
+ private get rowIdByResourceType();
375
+ init(): Promise<void>;
372
376
  deinit(): void;
373
377
  /**
374
378
  * Use {@link deinit} instead
@@ -1 +1 @@
1
- {"version":3,"file":"grid-pro-genesis-datasource.d.ts","sourceRoot":"","sources":["../../../src/grid-pro-genesis-datasource/grid-pro-genesis-datasource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,WAAW,EAAsB,MAAM,yBAAyB,CAAC;AAClF,OAAO,EACL,OAAO,EAEP,UAAU,EAWX,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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mBAAmB;IAqB3B,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,eAAe;IA0CvB,OAAO,CAAC,aAAa;IAMrB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IASjD,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;IAK9C,YAAY,CAAC,SAAS,EAAE,MAAM;CAItC"}
@@ -1,5 +1,5 @@
1
1
  import { __awaiter, __decorate } from "tslib";
2
- import { Connect, dataServerResultFilter, Datasource, DatasourceDefaults, FieldTypeEnum, MessageType, normaliseCriteria, } from '@genesislcap/foundation-comms';
2
+ import { Connect, dataServerResultFilter, Datasource, DatasourceDefaults, FieldTypeEnum, MessageType, normaliseCriteria, ResourceType, } from '@genesislcap/foundation-comms';
3
3
  import { LifecycleMixin } from '@genesislcap/foundation-utils';
4
4
  import { attr, customElement, DOM, observable } from '@microsoft/fast-element';
5
5
  import { FoundationElement } from '@microsoft/fast-foundation';
@@ -17,10 +17,11 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
17
17
  this.isSnapshot = false;
18
18
  this.maxRows = DatasourceDefaults.MAX_ROWS_250;
19
19
  this.maxView = DatasourceDefaults.MAX_VIEW_1000;
20
+ this.pollingInterval = DatasourceDefaults.REQ_REP_POLLING_INTERVAL_MS;
20
21
  this.movingView = false;
21
22
  this.reverse = false;
22
- this.rowId = 'ROW_REF';
23
23
  this.restartOnReconnection = false;
24
+ this.isRequestServer = false;
24
25
  this.requiresFullRowDataAndColDefs = true;
25
26
  this.dataSubWasLoggedOff = false;
26
27
  this.rows = new Map();
@@ -34,12 +35,12 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
34
35
  }
35
36
  connectedCallback() {
36
37
  super.connectedCallback();
37
- DOM.queueUpdate(() => {
38
+ DOM.queueUpdate(() => __awaiter(this, void 0, void 0, function* () {
38
39
  if (!this.shouldRunConnect)
39
40
  return;
40
- this.init();
41
- });
42
- this.connectionSub = this.connect.isConnectedSubject.subscribe((isConnected) => {
41
+ yield this.init();
42
+ }));
43
+ this.connectionSub = this.connect.isConnected$.subscribe((isConnected) => {
43
44
  if (isConnected && this.agGrid.attributes['ds-disconnected']) {
44
45
  this.agGrid.removeAttribute('ds-disconnected');
45
46
  if (this.restartOnReconnection) {
@@ -69,22 +70,36 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
69
70
  return this.parentElement;
70
71
  }
71
72
  // Genesis Specific
73
+ get rowIdByResourceType() {
74
+ if (this.rowId)
75
+ return this.rowId; // Allow user to override
76
+ if (this.isRequestServer)
77
+ return 'RECORD_ID'; // REQUEST_SERVER default record id
78
+ return 'ROW_REF'; // DATASERVER default record id
79
+ }
72
80
  init() {
73
- if (this.agGrid && this.resourceName && this.connect.isConnected) {
74
- const gridOptions = Object.assign({ getRowId: (params) => params.data[this.rowId] }, this.deferredGridOptions);
75
- this.agGrid.gridOptions = Object.assign({}, gridOptions);
76
- this.agGrid.addEventListener('onGridReady', () => __awaiter(this, void 0, void 0, function* () {
77
- yield this.loadResourceData();
78
- }), { once: true });
79
- const filterDebounceTime = 600;
80
- this.updateSub = this.update
81
- .pipe(skip(1), debounceTime(filterDebounceTime), tap((f) => logger.debug('filters (debounced): ', f)))
82
- .subscribe((value) => {
83
- this.loadResourceData(withoutFullInit);
84
- });
85
- return;
86
- }
87
- logger.warn(`Application not connected, falling back to local columnDefs/rowData`);
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ if (this.agGrid &&
83
+ this.datasource.validResourceName(this.resourceName) &&
84
+ this.connect.isConnected) {
85
+ const meta = yield this.connect.getMetadata(this.resourceName);
86
+ this.isRequestServer = meta.TYPE === ResourceType.REQUEST_SERVER;
87
+ this.rowId = this.rowIdByResourceType;
88
+ const gridOptions = Object.assign({ getRowId: (params) => params.data[this.rowId] }, this.deferredGridOptions);
89
+ this.agGrid.gridOptions = Object.assign({}, gridOptions);
90
+ this.agGrid.addEventListener('onGridReady', () => __awaiter(this, void 0, void 0, function* () {
91
+ yield this.loadResourceData();
92
+ }), { once: true });
93
+ const filterDebounceTime = 600;
94
+ this.updateSub = this.update
95
+ .pipe(skip(1), debounceTime(filterDebounceTime), tap((f) => logger.debug('filters (debounced): ', f)))
96
+ .subscribe((value) => {
97
+ this.loadResourceData(withoutFullInit);
98
+ });
99
+ return;
100
+ }
101
+ logger.warn(`Application not connected, falling back to local columnDefs/rowData`);
102
+ });
88
103
  }
89
104
  deinit() {
90
105
  this.reset();
@@ -106,10 +121,11 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
106
121
  this.connectionSub.unsubscribe();
107
122
  this.connectionSub = undefined;
108
123
  }
124
+ this.isRequestServer = false;
109
125
  this.requiresFullRowDataAndColDefs = true;
110
126
  this.dataSubWasLoggedOff = false;
111
127
  this.clearRowData();
112
- if (this.sourceRef) {
128
+ if (!this.isSnapshot && this.sourceRef) {
113
129
  this.connect.dataLogoff(this.sourceRef);
114
130
  this.sourceRef = undefined;
115
131
  }
@@ -126,6 +142,7 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
126
142
  this.agTransaction = undefined;
127
143
  (_b = (_a = this.agGrid) === null || _a === void 0 ? void 0 : _a.gridApi) === null || _b === void 0 ? void 0 : _b.setColumnDefs([]);
128
144
  (_d = (_c = this.agGrid) === null || _c === void 0 ? void 0 : _c.gridApi) === null || _d === void 0 ? void 0 : _d.setRowData([]);
145
+ this.rowId = undefined;
129
146
  }
130
147
  updateRowData(rowData) {
131
148
  const agColumnDefs = this.getAgColumnDefs(this.datasource.fieldMetadata);
@@ -179,7 +196,9 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
179
196
  if (Array.isArray(result))
180
197
  return result;
181
198
  if (result.REPLY) {
182
- return result.REPLY;
199
+ return this.datasourceKey && result.REPLY.length > 0
200
+ ? result.REPLY[0][this.datasourceKey]
201
+ : result.REPLY;
183
202
  }
184
203
  if (result.ROW) {
185
204
  return dataServerResultFilter(result).inserts;
@@ -197,14 +216,14 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
197
216
  reverse: this.reverse,
198
217
  maxRows: this.maxRows,
199
218
  maxView: this.maxView,
219
+ pollingInterval: this.pollingInterval,
200
220
  movingView: this.movingView,
201
221
  };
202
222
  }
203
223
  handleStreamResult(result) {
204
224
  if (!result)
205
225
  return;
206
- const isRequestServer = result.hasOwnProperty('REPLY');
207
- if (isRequestServer) {
226
+ if (this.isRequestServer) {
208
227
  this.applyRequestServerData(result);
209
228
  }
210
229
  else {
@@ -212,26 +231,37 @@ let GridProGenesisDatasource = class GridProGenesisDatasource extends LifecycleM
212
231
  }
213
232
  }
214
233
  applyRequestServerData(requestServerResult) {
215
- var _a, _b;
234
+ var _a;
216
235
  if (!Array.isArray(requestServerResult.REPLY) ||
217
236
  !((_a = requestServerResult.MESSAGE_TYPE) === null || _a === void 0 ? void 0 : _a.startsWith('REP_'))) {
218
237
  logger.error('received invalid RequestServerResult', requestServerResult);
219
238
  return;
220
239
  }
240
+ const requestServerData = this.datasourceKey && requestServerResult.REPLY.length > 0
241
+ ? requestServerResult.REPLY[0][this.datasourceKey]
242
+ : requestServerResult.REPLY;
221
243
  if (this.requiresFullRowDataAndColDefs) {
222
- if (this.rowId !== 'ROW_REF') {
223
- (_b = requestServerResult.REPLY) === null || _b === void 0 ? void 0 : _b.forEach((insertData) => {
224
- this.rows.set(insertData[this.rowId], insertData);
225
- });
226
- }
227
- const rowData = this.rows.size > 0 ? Array.from(this.rows.values()) : requestServerResult.REPLY;
244
+ requestServerData === null || requestServerData === void 0 ? void 0 : requestServerData.forEach((insertData) => {
245
+ this.rows.set(insertData[this.rowId], insertData);
246
+ });
247
+ const rowData = this.rows.size > 0 ? Array.from(this.rows.values()) : requestServerData;
228
248
  this.updateRowData(rowData);
229
249
  return;
230
250
  }
231
251
  this.agTransaction = { add: [], remove: [], update: [] };
232
- this.handleStreamInserts(requestServerResult.REPLY);
233
- const rowsToDelete = Array.from(this.rows.values()).filter((row) => !requestServerResult.REPLY.includes(row));
252
+ const rowsToUpdate = [];
253
+ const rowsToDelete = Array.from(this.rows.values()).filter((row) => {
254
+ const match = requestServerData.find((data) => data[this.rowId] === row[this.rowId]);
255
+ if (match) {
256
+ rowsToUpdate.push(match);
257
+ return false; // don't delete rows that need to be updated
258
+ }
259
+ return true; // delete rows that don't exist in requestServerData
260
+ });
261
+ const rowsToInsert = requestServerData.filter((data) => !this.rows.has(data[this.rowId]));
262
+ this.handleStreamInserts(rowsToInsert);
234
263
  this.handleStreamDeletes(rowsToDelete);
264
+ this.handleStreamUpdates(rowsToUpdate);
235
265
  this.agGrid.gridApi.applyTransactionAsync(this.agTransaction);
236
266
  }
237
267
  applyDataserverData(dataServerResult) {
@@ -357,6 +387,9 @@ __decorate([
357
387
  __decorate([
358
388
  attr({ attribute: 'max-view' })
359
389
  ], GridProGenesisDatasource.prototype, "maxView", void 0);
390
+ __decorate([
391
+ attr({ attribute: 'polling-interval' })
392
+ ], GridProGenesisDatasource.prototype, "pollingInterval", void 0);
360
393
  __decorate([
361
394
  attr({ attribute: 'moving-view' })
362
395
  ], GridProGenesisDatasource.prototype, "movingView", void 0);
@@ -375,6 +408,9 @@ __decorate([
375
408
  __decorate([
376
409
  attr({ attribute: 'row-id' })
377
410
  ], GridProGenesisDatasource.prototype, "rowId", void 0);
411
+ __decorate([
412
+ attr({ attribute: 'datasoruce-key' })
413
+ ], GridProGenesisDatasource.prototype, "datasourceKey", void 0);
378
414
  __decorate([
379
415
  attr({ mode: 'boolean', attribute: 'restart-on-reconnection' })
380
416
  ], GridProGenesisDatasource.prototype, "restartOnReconnection", void 0);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/grid-pro",
3
3
  "description": "Genesis Foundation AG Grid",
4
- "version": "14.12.2",
4
+ "version": "14.12.3-alpha-964c9f1.0",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -23,7 +23,7 @@
23
23
  "test": "echo \"Error: no test specified\""
24
24
  },
25
25
  "devDependencies": {
26
- "@genesislcap/foundation-testing": "^14.12.2",
26
+ "@genesislcap/foundation-testing": "14.12.3-alpha-964c9f1.0",
27
27
  "@playwright/test": "^1.18.1",
28
28
  "@rollup/plugin-commonjs": "^21.0.1",
29
29
  "@rollup/plugin-node-resolve": "^13.1.3",
@@ -74,9 +74,9 @@
74
74
  "webpack-merge": "^5.7.3"
75
75
  },
76
76
  "dependencies": {
77
- "@genesislcap/foundation-comms": "^14.12.2",
78
- "@genesislcap/foundation-ui": "^14.12.2",
79
- "@genesislcap/foundation-utils": "^14.12.2",
77
+ "@genesislcap/foundation-comms": "14.12.3-alpha-964c9f1.0",
78
+ "@genesislcap/foundation-ui": "14.12.3-alpha-964c9f1.0",
79
+ "@genesislcap/foundation-utils": "14.12.3-alpha-964c9f1.0",
80
80
  "@microsoft/fast-colors": "^5.1.4",
81
81
  "@microsoft/fast-components": "^2.21.3",
82
82
  "@microsoft/fast-element": "^1.7.0",
@@ -97,5 +97,5 @@
97
97
  "publishConfig": {
98
98
  "access": "public"
99
99
  },
100
- "gitHead": "cbd0a8fd35372ecfc6c35c191824374c1919f07a"
100
+ "gitHead": "1ae6551a0ab1e66c7c315853689f2fa9dcabed98"
101
101
  }