@adaptabletools/adaptable-plugin-ipushpull-cjs 20.0.0-canary.2 → 20.0.0-canary.20

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-plugin-ipushpull-cjs",
3
- "version": "20.0.0-canary.2",
3
+ "version": "20.0.0-canary.20",
4
4
  "description": "",
5
5
  "homepage": "http://www.adaptabletools.com/",
6
6
  "author": {
@@ -18,8 +18,7 @@
18
18
  "redux": "^5.0.1",
19
19
  "styled-components": "^4.4.1",
20
20
  "tinycolor2": "^1.4.2",
21
- "tslib": "^2.8.1",
22
- "@adaptabletools/adaptable-cjs": "20.0.0-canary.2"
21
+ "tslib": "^2.8.1"
23
22
  },
24
23
  "peerDependencies": {}
25
24
  }
@@ -106,58 +106,55 @@ class PushPullModule extends AdaptableModuleBase_1.AdaptableModuleBase {
106
106
  return this.ippService;
107
107
  }
108
108
  sendNewLiveData() {
109
- //we wait for the last sendNewLiveData to finish
110
- if (this.isSendingData == true) {
109
+ // We wait for the last sendNewLiveData to finish
110
+ if (this.isSendingData === true) {
111
111
  this.throttledRecomputeAndSendLiveDataEvent();
112
112
  return;
113
113
  }
114
- let currentLiveIPushPullReport = this.getIPPApi().getCurrentLiveIPushPullReport();
114
+ const currentLiveIPushPullReport = this.getIPPApi().getCurrentLiveIPushPullReport();
115
115
  if (currentLiveIPushPullReport) {
116
116
  this.isSendingData = true;
117
- let report = this.api.exportApi.getReportByName(currentLiveIPushPullReport.ReportName);
118
- let reportAsArray = this.api.exportApi.internalApi.getReportDataAsArray(report);
119
- const currentData = JSON.stringify(reportAsArray);
120
- if (currentData === this.lastData) {
121
- this.adaptable.logger.warn(EQUAL_DATA_ERR);
122
- this.isSendingData = false;
123
- return;
124
- }
125
- Promise.resolve()
126
- .then(() => {
127
- return new Promise((resolve, reject) => {
128
- if (reportAsArray) {
129
- resolve(reportAsArray);
130
- }
131
- else {
132
- reject('no data in the report');
133
- }
134
- });
117
+ this.api.exportApi
118
+ .getReportData(currentLiveIPushPullReport.ReportName, 'JSON')
119
+ .then((exportResultData) => {
120
+ if (exportResultData?.type !== 'json' || !exportResultData.data) {
121
+ throw new Error('No data in the report');
122
+ }
123
+ const reportDataAsArray = this.api.exportApi.internalApi.convertReportDataToArray(exportResultData.data);
124
+ const currentData = JSON.stringify(reportDataAsArray);
125
+ if (currentData === this.lastData) {
126
+ this.adaptable.logger.warn(EQUAL_DATA_ERR);
127
+ this.isSendingData = false;
128
+ throw new Error(EQUAL_DATA_ERR); // Using throw to exit the promise chain
129
+ }
130
+ return { reportDataAsArray, currentData };
135
131
  })
136
- .then((reportAsArray) => {
137
- return this.getIPPService().pushData(currentLiveIPushPullReport.Page, reportAsArray);
132
+ .then(({ reportDataAsArray, currentData }) => {
133
+ return this.getIPPService()
134
+ .pushData(currentLiveIPushPullReport.Page, reportDataAsArray)
135
+ .then(() => currentData); // Pass currentData to the next then
138
136
  })
139
- .then(() => {
137
+ .then((currentData) => {
140
138
  this.lastData = currentData;
139
+ this.adaptable.logger.success('All live report data sent');
140
+ this.isSendingData = false;
141
141
  return this.api.exportApi.internalApi.publishLiveLiveDataChangedEvent('ipushpull', 'LiveDataUpdated', currentLiveIPushPullReport);
142
142
  })
143
143
  .catch((reason) => {
144
- this.adaptable.logger.warn('Failed to send data to ipushpull for [' + currentLiveIPushPullReport.ReportName + ']', reason);
145
- this.stopLiveData();
146
- let errorMessage = 'Export Failed';
147
- if (reason) {
148
- errorMessage += ': ' + reason;
144
+ // Skip logging for expected cases
145
+ if (reason?.message !== EQUAL_DATA_ERR) {
146
+ this.isSendingData = false;
147
+ this.adaptable.logger.warn('Failed to send data to ipushpull for [' +
148
+ currentLiveIPushPullReport.ReportName +
149
+ ']', reason);
150
+ this.stopLiveData();
151
+ let errorMessage = 'Export Failed';
152
+ if (reason) {
153
+ errorMessage += ': ' + reason;
154
+ }
155
+ errorMessage += '. This live export has been cancelled.';
156
+ this.api.alertApi.showAlertError('ipushpull Export Error', errorMessage);
149
157
  }
150
- errorMessage += '. This live export has been cancelled.';
151
- this.api.alertApi.showAlertError('ipushpull Export Error', errorMessage);
152
- });
153
- Promise.resolve()
154
- .then(() => {
155
- this.adaptable.logger.success('All live report data sent');
156
- this.isSendingData = false;
157
- })
158
- .catch(() => {
159
- this.adaptable.logger.warn('Failed to send data');
160
- this.isSendingData = false;
161
158
  });
162
159
  }
163
160
  }
@@ -165,13 +162,16 @@ class PushPullModule extends AdaptableModuleBase_1.AdaptableModuleBase {
165
162
  this.getIPPService()
166
163
  .loadPage(iPushPullReport.Folder, iPushPullReport.Page)
167
164
  .then(() => {
168
- let report = this.api.exportApi.getReportByName(iPushPullReport.ReportName);
169
- if (report) {
170
- let reportAsArray = this.api.exportApi.internalApi.getReportDataAsArray(report);
171
- if (reportAsArray) {
172
- this.getIPPService().pushData(iPushPullReport.Page, reportAsArray);
173
- }
165
+ return this.api.exportApi.getReportData(iPushPullReport.ReportName, 'JSON');
166
+ })
167
+ .then((exportResultData) => {
168
+ if (exportResultData?.type === 'json' && exportResultData?.data) {
169
+ const reportDataAsArray = this.api.exportApi.internalApi.convertReportDataToArray(exportResultData.data);
170
+ return this.getIPPService().pushData(iPushPullReport.Page, reportDataAsArray);
174
171
  }
172
+ })
173
+ .catch((error) => {
174
+ this.adaptable.logger.warn(`Failed to send snapshot for report [${iPushPullReport.ReportName}]`, error);
175
175
  });
176
176
  }
177
177
  startLiveData(iPushPullReport) {