@adaptabletools/adaptable-cjs 20.0.0-canary.6 → 20.0.0-canary.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaptabletools/adaptable-cjs",
3
- "version": "20.0.0-canary.6",
3
+ "version": "20.0.0-canary.7",
4
4
  "description": "Powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements",
5
5
  "keywords": [
6
6
  "web-components",
@@ -162,9 +162,9 @@ export interface ExternalReport {
162
162
  */
163
163
  name: string;
164
164
  /**
165
- * Function invoked to return the data (in the form of a `ReportData` object)
165
+ * Function invoked to return the data (in the form of a `ExportResultData` object)
166
166
  */
167
- onRunReport: () => ReportData;
167
+ onExport: (context: BaseExportContext) => Promise<ExportResultData>;
168
168
  }
169
169
  /**
170
170
  * Defines a custom Export destination
@@ -1,5 +1,5 @@
1
1
  import { AdaptableForm } from '../PredefinedConfig/Common/AdaptableForm';
2
- import { ExportState, Report, ReportData, ReportFormatType, ReportNameType, SystemReportFormat, SystemReportName } from '../PredefinedConfig/ExportState';
2
+ import { ExportState, Report, ReportFormatType, ReportNameType, SystemReportFormat, SystemReportName } from '../PredefinedConfig/ExportState';
3
3
  import { CustomDestination, ExportDestinationType, ExportFormContext, ExportResultData, ExternalReport, SystemExportDestination } from '../AdaptableOptions/ExportOptions';
4
4
  import { AdaptableColumn } from '../types';
5
5
  /**
@@ -139,11 +139,6 @@ export interface ExportApi {
139
139
  * @param report Report to Check
140
140
  */
141
141
  isExternalReport(report: Report): boolean;
142
- /**
143
- * Runs the report function of the ExternalReport with the given reportName
144
- * @param reportName external report name
145
- */
146
- runExternalReport(reportName: string): ReportData | undefined;
147
142
  /**
148
143
  * Returns whether the given column is exportable
149
144
  */
@@ -1,5 +1,5 @@
1
1
  import { ExportApi } from '../ExportApi';
2
- import { ExportState, Report, ReportData, ReportFormatType, ReportNameType, SystemReportFormat, SystemReportName } from '../../PredefinedConfig/ExportState';
2
+ import { ExportState, Report, ReportFormatType, ReportNameType, SystemReportFormat, SystemReportName } from '../../PredefinedConfig/ExportState';
3
3
  import { ApiBase } from './ApiBase';
4
4
  import { AdaptableForm } from '../../PredefinedConfig/Common/AdaptableForm';
5
5
  import { CustomDestination, ExportDestinationType, ExportFormContext, ExportResultData, ExternalReport, SystemExportDestination } from '../../AdaptableOptions/ExportOptions';
@@ -36,7 +36,6 @@ export declare class ExportApiImpl extends ApiBase implements ExportApi {
36
36
  getCustomReports(): Report[];
37
37
  getExternalReports(): ExternalReport[];
38
38
  isExternalReport(report: Report): boolean;
39
- runExternalReport(externalReportName: string): ReportData | undefined;
40
39
  isColumnExportable(adaptableColumn: AdaptableColumn): boolean;
41
40
  getSupportedExportDestinations(reportFormat: ReportFormatType): ExportDestinationType[];
42
41
  exportReport(reportName: ReportNameType, format: ReportFormatType, destination?: ExportDestinationType): void;
@@ -136,14 +136,6 @@ class ExportApiImpl extends ApiBase_1.ApiBase {
136
136
  isExternalReport(report) {
137
137
  return this.getExternalReports()?.find((cr) => cr.name == report.Name) != null;
138
138
  }
139
- runExternalReport(externalReportName) {
140
- const externalReport = this.getExternalReports()?.find((cr) => cr.name == externalReportName);
141
- if (!externalReport) {
142
- this.logWarn(`External Report '${externalReportName}' not found!`);
143
- return undefined;
144
- }
145
- return externalReport.onRunReport();
146
- }
147
139
  isColumnExportable(adaptableColumn) {
148
140
  const isExportableFn = this.getExportOptions().isColumnExportable;
149
141
  if (typeof isExportableFn === 'function') {
@@ -172,6 +164,20 @@ class ExportApiImpl extends ApiBase_1.ApiBase {
172
164
  exportReport(reportName, format, destination = 'Download') {
173
165
  let report = this.getReportByName(reportName);
174
166
  if (this.checkItemExists(report, reportName, 'Report')) {
167
+ if (this.isExternalReport(report)) {
168
+ // Handle external report
169
+ this.internalApi
170
+ .getExternalReportData(reportName, format, destination)
171
+ .then((reportData) => {
172
+ if (reportData) {
173
+ this.internalApi.sendReportToDestination(reportData, report, format, destination);
174
+ }
175
+ })
176
+ .catch((error) => {
177
+ this.logWarn(`Failed to get external report data for '${reportName}': ${error}`);
178
+ });
179
+ return;
180
+ }
175
181
  this._adaptable.agGridExportAdapter
176
182
  .exportData({
177
183
  report,
@@ -81,13 +81,14 @@ class ActionColumnInternalApi extends ApiBase_1.ApiBase {
81
81
  return { actionButtons, actionColumn };
82
82
  }
83
83
  updateAllActionColumnButtons(actionButtons) {
84
- return actionButtons.map((actionButton) => ({
85
- ...actionButton,
86
- Uuid: (0, Uuid_1.createUuid)(),
87
- command: actionButton.command == undefined
88
- ? undefined
89
- : this.updateActionButtonCommand(actionButton),
90
- }));
84
+ return actionButtons.map((actionButton) => {
85
+ actionButton = { ...actionButton };
86
+ actionButton.Uuid = (0, Uuid_1.createUuid)();
87
+ if (actionButton.command) {
88
+ this.updateActionButtonCommand(actionButton);
89
+ }
90
+ return actionButton;
91
+ });
91
92
  }
92
93
  updateActionButtonCommand(button) {
93
94
  switch (button.command) {
@@ -96,7 +97,7 @@ class ActionColumnInternalApi extends ApiBase_1.ApiBase {
96
97
  this.getRowFormApi().displayCreateRowForm();
97
98
  };
98
99
  button.tooltip = button.tooltip ? button.tooltip : 'Create Row';
99
- button.icon = {
100
+ button.icon = button.icon ?? {
100
101
  name: 'add',
101
102
  };
102
103
  break;
@@ -105,7 +106,7 @@ class ActionColumnInternalApi extends ApiBase_1.ApiBase {
105
106
  this.getRowFormApi().displayCloneRowForm(context.primaryKeyValue);
106
107
  };
107
108
  button.tooltip = button.tooltip ? button.tooltip : 'Clone Row';
108
- button.icon = {
109
+ button.icon = button.icon ?? {
109
110
  name: 'clone',
110
111
  };
111
112
  break;
@@ -120,22 +121,18 @@ class ActionColumnInternalApi extends ApiBase_1.ApiBase {
120
121
  this.getRowFormOptions().onRowFormSubmit?.(eventInfo);
121
122
  };
122
123
  button.tooltip = button.tooltip ? button.tooltip : 'Delete Row';
123
- button.icon = button.icon
124
- ? button.icon
125
- : {
126
- name: 'delete',
127
- };
124
+ button.icon = button.icon ?? {
125
+ name: 'delete',
126
+ };
128
127
  break;
129
128
  case 'edit':
130
129
  button.onClick = (button, context) => {
131
130
  this.getRowFormApi().displayEditRowForm(context.primaryKeyValue);
132
131
  };
133
132
  button.tooltip = button.tooltip ? button.tooltip : 'Edit Row';
134
- button.icon = button.icon
135
- ? button.icon
136
- : {
137
- name: 'edit',
138
- };
133
+ button.icon = button.icon ?? {
134
+ name: 'edit',
135
+ };
139
136
  break;
140
137
  }
141
138
  }
@@ -21,12 +21,7 @@ export declare class ExportInternalApi extends ApiBase {
21
21
  getReportColumnScopeShortDescription(report: Report): string[];
22
22
  getReportColumnScopeLongDescription(report: Report): string;
23
23
  getReportExpressionDescription(report: Report, cols: AdaptableColumn[]): string;
24
- getReportDataColumns(report: Report, includePrimaryKey?: boolean): AdaptableColumn[];
25
- getReportDataRows(report: Report, columns: AdaptableColumn[], includePrimaryKey?: boolean): Record<string, any>[];
26
- getReportData(report: Report, includePrimaryKey?: boolean): ReportData;
27
- getReportDataAsArray(report: Report, includePrimaryKey?: boolean): any[][];
28
24
  convertReportDataToArray(reportData: ReportData): any[][];
29
- getRowObjectForColumnIds(rowNode: IRowNode, columnIds: string[], reportName: string): Record<string, any>;
30
25
  publishLiveLiveDataChangedEvent(reportDestination: 'ipushpull' | 'OpenFin', liveDataTrigger: 'Connected' | 'Disconnected' | 'SnapshotSent' | 'LiveDataStarted' | 'LiveDataStopped' | 'LiveDataUpdated', liveReport?: any): void;
31
26
  getCellExportValueFromRowNode(rowNode: IRowNode, columnId: string, isVisualReport?: boolean): any;
32
27
  getCellExportValueFromRawValue(rowNode: IRowNode, cellRawValue: any, columnId: string, isVisualReport?: boolean): any;
@@ -36,4 +31,5 @@ export declare class ExportInternalApi extends ApiBase {
36
31
  sendReportToDestination(reportResult: ExportResultData, report: Report, format: ReportFormatType, destination: ExportDestinationType): void;
37
32
  private sendReportToCustomDestination;
38
33
  buildBaseExportContext(reportName: ReportNameType, reportFormat: ReportFormatType, exportDestination?: ExportDestinationType): BaseExportContext;
34
+ getExternalReportData(externalReportName: ReportNameType, reportFormat: ReportFormatType, exportDestination: ExportDestinationType): Promise<ExportResultData | undefined>;
39
35
  }
@@ -2,18 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExportInternalApi = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const groupBy_1 = tslib_1.__importDefault(require("lodash/groupBy"));
6
5
  const ApiBase_1 = require("../Implementation/ApiBase");
7
6
  const Uuid_1 = require("../../PredefinedConfig/Uuid");
8
7
  const GeneralConstants_1 = require("../../Utilities/Constants/GeneralConstants");
9
- const ModuleConstants_1 = require("../../Utilities/Constants/ModuleConstants");
10
- const ArrayExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/ArrayExtensions"));
11
8
  const StringExtensions_1 = tslib_1.__importDefault(require("../../Utilities/Extensions/StringExtensions"));
12
9
  const FormatHelper_1 = tslib_1.__importStar(require("../../Utilities/Helpers/FormatHelper"));
13
10
  const Helper_1 = tslib_1.__importDefault(require("../../Utilities/Helpers/Helper"));
14
11
  const PopupRedux = tslib_1.__importStar(require("../../Redux/ActionsReducers/PopupRedux"));
15
12
  const InternalRedux_1 = require("../../Redux/ActionsReducers/InternalRedux");
16
- const AdaptableLogger_1 = require("../../agGrid/AdaptableLogger");
17
13
  class ExportInternalApi extends ApiBase_1.ApiBase {
18
14
  /**
19
15
  * Value Items for Report Name Selection
@@ -215,7 +211,6 @@ class ExportInternalApi extends ApiBase_1.ApiBase {
215
211
  return `[${report.Name}]`;
216
212
  }
217
213
  else {
218
- // FIXME AFL: maybe fihnd a better description?
219
214
  switch (report.ReportRowScope) {
220
215
  case 'AllRows':
221
216
  return '[All Rows]';
@@ -228,138 +223,12 @@ class ExportInternalApi extends ApiBase_1.ApiBase {
228
223
  }
229
224
  }
230
225
  }
231
- getReportDataColumns(report, includePrimaryKey = false) {
232
- let reportColumns = [];
233
- let gridColumns = this.getAdaptableApi().columnApi.getExportableColumns();
234
- if (this.getAdaptableApi().exportApi.isExternalReport(report)) {
235
- return reportColumns;
236
- }
237
- // first get the cols depending on the Column Scope
238
- switch (report.ReportColumnScope) {
239
- case 'AllColumns':
240
- reportColumns = gridColumns;
241
- break;
242
- case 'VisibleColumns':
243
- reportColumns = gridColumns.filter((c) => c.visible);
244
- break;
245
- case 'SelectedColumns':
246
- // we extract the selected columns from the grid columns to preserve the grid column order
247
- const selectedColumnIds = this.getAdaptableApi()
248
- .gridApi.getSelectedCellInfo()
249
- .columns.map((column) => column.columnId);
250
- reportColumns = gridColumns.filter((gridColumn) => selectedColumnIds.includes(gridColumn.columnId));
251
- break;
252
- case 'ScopeColumns':
253
- if ('ColumnIds' in report.Scope) {
254
- reportColumns = report.Scope.ColumnIds.map((columnId) => this.getAdaptableApi().columnApi.getColumnWithColumnId(columnId)).filter((c) => c);
255
- }
256
- else {
257
- reportColumns = this.getAdaptableApi().columnScopeApi.getColumnsInScope(report.Scope);
258
- }
259
- break;
260
- }
261
- if (includePrimaryKey) {
262
- const pkColumn = reportColumns.find((column) => column.columnId === this.getAdaptableApi().optionsApi.getPrimaryKey());
263
- // TODO simplify after we fix the IsPrimaryKey bug
264
- // const pkColumn = reportColumns.find(column => column.IsPrimaryKey);
265
- if (!pkColumn && !!this.getAdaptableApi().columnApi.getPrimaryKeyColumn()) {
266
- reportColumns.push(this.getAdaptableApi().columnApi.getPrimaryKeyColumn());
267
- }
268
- }
269
- return reportColumns;
270
- }
271
- getReportDataRows(report, columns, includePrimaryKey) {
272
- if (ArrayExtensions_1.default.IsNullOrEmpty(columns)) {
273
- return [];
274
- }
275
- const columnIds = columns.map((column) => column.columnId);
276
- const resultRowData = [];
277
- switch (report.ReportRowScope) {
278
- case 'AllRows':
279
- this.getAdaptableInternalApi().forAllRowNodesDo((rowNode) => {
280
- resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds, report.Name));
281
- });
282
- break;
283
- case 'VisibleRows':
284
- this.getAdaptableInternalApi().forAllVisibleRowNodesDo((rowNode) => {
285
- resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds, report.Name));
286
- });
287
- break;
288
- case 'ExpressionRows':
289
- this.getAdaptableInternalApi().forAllRowNodesDo((rowNode) => {
290
- try {
291
- if (this.getAdaptableApi()
292
- .internalApi.getQueryLanguageService()
293
- .evaluateBooleanExpression(report.Query?.BooleanExpression, ModuleConstants_1.ExportModuleId, rowNode)) {
294
- resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds, report.Name));
295
- }
296
- }
297
- catch (error) {
298
- (0, AdaptableLogger_1.errorOnce)(error.message);
299
- }
300
- });
301
- break;
302
- case 'SelectedRows':
303
- // CellSelection
304
- const selectedCellInfo = this.getAdaptableApi().gridApi.getSelectedCellInfo();
305
- const { gridCells: GridCells } = selectedCellInfo;
306
- let selectedCellsByPrimaryKey = (0, groupBy_1.default)(GridCells, 'primaryKeyValue');
307
- // we iterate over all visibleRowNodes to preserve the current order
308
- this.getAdaptableInternalApi().forAllVisibleRowNodesDo((rowNode) => {
309
- const rowPrimaryKeyValue = this.getAdaptableApi().gridApi.getPrimaryKeyValueForRowNode(rowNode);
310
- const selectedRowCells = selectedCellsByPrimaryKey[rowPrimaryKeyValue];
311
- if (selectedRowCells) {
312
- const selectedRowColumnIds = selectedRowCells.map((rowCell) => rowCell.column.columnId);
313
- const selectedColumnIds = columnIds.filter((columnId) => selectedRowColumnIds.includes(columnId));
314
- const row = this.getRowObjectForColumnIds(rowNode, selectedColumnIds, report.Name);
315
- if (includePrimaryKey) {
316
- row[this.getAdaptableApi().optionsApi.getPrimaryKey()] = rowPrimaryKeyValue;
317
- }
318
- resultRowData.push(row);
319
- }
320
- });
321
- // Row Selection
322
- const selectedRowInfo = this.getAdaptableApi().gridApi.getSelectedRowInfo();
323
- const selectedGridRowPrimaryKeys = selectedRowInfo?.gridRows
324
- ?.filter((gr) => gr.rowInfo.isGroup == false)
325
- .map((gridRow) => gridRow.primaryKeyValue) ?? [];
326
- if (selectedGridRowPrimaryKeys.length) {
327
- this.getAdaptableInternalApi().forAllRowNodesDo((rowNode) => {
328
- const rowPrimaryKeyValue = this.getAdaptableApi().gridApi.getPrimaryKeyValueForRowNode(rowNode);
329
- if (selectedGridRowPrimaryKeys.includes(rowPrimaryKeyValue)) {
330
- resultRowData.push(this.getRowObjectForColumnIds(rowNode, columnIds, report.Name));
331
- }
332
- });
333
- }
334
- break;
335
- }
336
- return resultRowData;
337
- }
338
- getReportData(report, includePrimaryKey = false) {
339
- if (this.getAdaptableApi().exportApi.isExternalReport(report)) {
340
- return this.getAdaptableApi().exportApi.runExternalReport(report.Name);
341
- }
342
- const columns = this.getReportDataColumns(report, includePrimaryKey);
343
- const rows = this.getReportDataRows(report, columns, includePrimaryKey);
344
- return { columns, rows };
345
- }
346
- getReportDataAsArray(report, includePrimaryKey = false) {
347
- const reportData = this.getReportData(report, includePrimaryKey);
348
- return this.convertReportDataToArray(reportData);
349
- }
350
226
  convertReportDataToArray(reportData) {
351
227
  return [
352
228
  reportData.columns.map((column) => column.friendlyName),
353
229
  ...reportData.rows.map((row) => reportData.columns.map((column) => row[column.columnId])),
354
230
  ];
355
231
  }
356
- getRowObjectForColumnIds(rowNode, columnIds, reportName) {
357
- return columnIds.reduce((result, columnId) => {
358
- // FIXME AFL if this method remains, 'false' should be replaced with dynamic value
359
- result[columnId] = this.getCellExportValueFromRowNode(rowNode, columnId, false);
360
- return result;
361
- }, {});
362
- }
363
232
  publishLiveLiveDataChangedEvent(reportDestination, liveDataTrigger, liveReport) {
364
233
  const liveDataChangedInfo = {
365
234
  ...this.getAdaptableInternalApi().buildBaseContext(),
@@ -494,5 +363,15 @@ class ExportInternalApi extends ApiBase_1.ApiBase {
494
363
  exportDestination,
495
364
  };
496
365
  }
366
+ getExternalReportData(externalReportName, reportFormat, exportDestination) {
367
+ const externalReport = this.getExportApi()
368
+ .getExternalReports()
369
+ ?.find((cr) => cr.name == externalReportName);
370
+ if (!externalReport) {
371
+ this.logWarn(`External Report '${externalReportName}' not found!`);
372
+ return undefined;
373
+ }
374
+ return externalReport.onExport(this.buildBaseExportContext(externalReportName, reportFormat, exportDestination));
375
+ }
497
376
  }
498
377
  exports.ExportInternalApi = ExportInternalApi;
@@ -86,19 +86,6 @@ export interface ReportData {
86
86
  */
87
87
  pivotColumnIds?: string[];
88
88
  }
89
- /**
90
- * Row Data in the Report
91
- */
92
- export interface ReportRow {
93
- /**
94
- * Data for the row
95
- */
96
- data: Record<string, any>;
97
- /**
98
- * Optional children rows for grouped data
99
- */
100
- children?: ReportRow[];
101
- }
102
89
  /**
103
90
  * System report names provided by AdapTable
104
91
  */
@@ -23,6 +23,7 @@ export declare class AgGridExportAdapter {
23
23
  private get agGridApi();
24
24
  private get adaptableApi();
25
25
  private get exportOptions();
26
+ private get logger();
26
27
  static getExcelClassNameForCell(colId: string, primaryKeyValue: any, userDefinedCellClass?: string | string[]): string;
27
28
  destroy(): void;
28
29
  exportData(config: ExportConfig): Promise<null | ExportResultData>;
@@ -33,6 +33,9 @@ class AgGridExportAdapter {
33
33
  get exportOptions() {
34
34
  return this._adaptableInstance.api.optionsApi.getExportOptions();
35
35
  }
36
+ get logger() {
37
+ return this._adaptableInstance.logger;
38
+ }
36
39
  static getExcelClassNameForCell(colId, primaryKeyValue, userDefinedCellClass) {
37
40
  let excelClassName = `--excel-cell-${colId}-${primaryKeyValue}`;
38
41
  if (excelClassName.indexOf(' ') > 0) {
@@ -102,8 +105,7 @@ class AgGridExportAdapter {
102
105
  };
103
106
  }
104
107
  catch (error) {
105
- // FIXME AFL improve logging
106
- console.error(error);
108
+ this.logger.consoleError(`Error exporting ${report.Name} in ${format} format to ${config.destination}`, error);
107
109
  }
108
110
  finally {
109
111
  /**
package/src/env.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  NEXT_PUBLIC_INFINITE_TABLE_LICENSE_KEY: "StartDate=2021-06-29|EndDate=2030-01-01|Owner=Adaptable|Type=distribution|TS=1624971462479|C=137829811,1004007071,2756196225,1839832928,3994409405,636616862" || '',
5
- PUBLISH_TIMESTAMP: 1741253368753 || Date.now(),
6
- VERSION: "20.0.0-canary.6" || '--current-version--',
5
+ PUBLISH_TIMESTAMP: 1741274250893 || Date.now(),
6
+ VERSION: "20.0.0-canary.7" || '--current-version--',
7
7
  };