@sankhyalabs/sankhyablocks 5.2.2 → 5.3.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.
Files changed (64) hide show
  1. package/README.md +0 -3
  2. package/dist/cjs/{ConfigStorage-98c5108f.js → ConfigStorage-91adf3fe.js} +1 -1
  3. package/dist/cjs/{DataFetcher-4fbdb64a.js → DataFetcher-a9d0228f.js} +63 -26
  4. package/dist/cjs/{SnkFormConfigManager-88559b73.js → SnkFormConfigManager-e1a10283.js} +2 -2
  5. package/dist/cjs/{form-config-fetcher-6b19bf3b.js → form-config-fetcher-fa19680a.js} +1 -1
  6. package/dist/cjs/{pesquisa-fetcher-1b559332.js → pesquisa-fetcher-954b74c3.js} +1 -1
  7. package/dist/cjs/snk-application.cjs.entry.js +8 -8
  8. package/dist/cjs/snk-crud.cjs.entry.js +2 -2
  9. package/dist/cjs/snk-data-exporter.cjs.entry.js +1 -1
  10. package/dist/cjs/snk-detail-view.cjs.entry.js +6 -6
  11. package/dist/cjs/snk-filter-bar.cjs.entry.js +3 -3
  12. package/dist/cjs/snk-form-config.cjs.entry.js +2 -2
  13. package/dist/cjs/snk-form.cjs.entry.js +4 -4
  14. package/dist/cjs/snk-grid-config.cjs.entry.js +3 -3
  15. package/dist/cjs/snk-grid.cjs.entry.js +3 -3
  16. package/dist/cjs/{snk-guides-viewer-21a2c43c.js → snk-guides-viewer-7db960c2.js} +3 -3
  17. package/dist/cjs/snk-guides-viewer.cjs.entry.js +6 -6
  18. package/dist/cjs/snk-simple-crud.cjs.entry.js +5 -4
  19. package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +4 -4
  20. package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +3 -2
  21. package/dist/collection/lib/http/data-fetcher/DataFetcher.js +64 -27
  22. package/dist/components/DataFetcher.js +64 -27
  23. package/dist/components/snk-application2.js +4 -4
  24. package/dist/components/snk-simple-crud.js +3 -2
  25. package/dist/esm/{ConfigStorage-479e3228.js → ConfigStorage-ac77ff39.js} +1 -1
  26. package/dist/esm/{DataFetcher-caa61f2c.js → DataFetcher-b3d8b2d5.js} +64 -27
  27. package/dist/esm/{SnkFormConfigManager-960d808d.js → SnkFormConfigManager-40609500.js} +2 -2
  28. package/dist/esm/{form-config-fetcher-74e3e14b.js → form-config-fetcher-018e7e73.js} +1 -1
  29. package/dist/esm/{pesquisa-fetcher-c86787c1.js → pesquisa-fetcher-bd6af0e3.js} +1 -1
  30. package/dist/esm/snk-application.entry.js +8 -8
  31. package/dist/esm/snk-crud.entry.js +2 -2
  32. package/dist/esm/snk-data-exporter.entry.js +1 -1
  33. package/dist/esm/snk-detail-view.entry.js +6 -6
  34. package/dist/esm/snk-filter-bar.entry.js +3 -3
  35. package/dist/esm/snk-form-config.entry.js +2 -2
  36. package/dist/esm/snk-form.entry.js +4 -4
  37. package/dist/esm/snk-grid-config.entry.js +3 -3
  38. package/dist/esm/snk-grid.entry.js +3 -3
  39. package/dist/esm/{snk-guides-viewer-c9e5aa60.js → snk-guides-viewer-1e7c21f6.js} +3 -3
  40. package/dist/esm/snk-guides-viewer.entry.js +6 -6
  41. package/dist/esm/snk-simple-crud.entry.js +5 -4
  42. package/dist/sankhyablocks/{p-86667fdf.js → p-0d81236c.js} +1 -1
  43. package/dist/sankhyablocks/{p-75a83156.js → p-11028eba.js} +2 -2
  44. package/dist/sankhyablocks/{p-69af76d4.entry.js → p-1c17eecf.entry.js} +1 -1
  45. package/dist/sankhyablocks/p-41d92871.js +1 -0
  46. package/dist/sankhyablocks/{p-9060cd55.entry.js → p-51fd8fd7.entry.js} +1 -1
  47. package/dist/sankhyablocks/{p-5fc11c5d.js → p-52ed2a18.js} +1 -1
  48. package/dist/sankhyablocks/{p-6ad356c2.entry.js → p-6516f35a.entry.js} +1 -1
  49. package/dist/sankhyablocks/{p-8293879e.entry.js → p-6b505973.entry.js} +1 -1
  50. package/dist/sankhyablocks/{p-39a49898.js → p-703dddb9.js} +1 -1
  51. package/dist/sankhyablocks/{p-76f04efe.entry.js → p-7621806d.entry.js} +1 -1
  52. package/dist/sankhyablocks/p-79f01b63.entry.js +1 -0
  53. package/dist/sankhyablocks/{p-8ade557c.entry.js → p-81e85890.entry.js} +1 -1
  54. package/dist/sankhyablocks/{p-280b1321.entry.js → p-d61759a5.entry.js} +1 -1
  55. package/dist/sankhyablocks/{p-e999631f.entry.js → p-d9b4eebb.entry.js} +1 -1
  56. package/dist/sankhyablocks/{p-664c1543.js → p-e0aa5838.js} +1 -1
  57. package/dist/sankhyablocks/{p-046b2563.entry.js → p-f4d36823.entry.js} +1 -1
  58. package/dist/sankhyablocks/{p-5b84b0c5.entry.js → p-fac37198.entry.js} +1 -1
  59. package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
  60. package/dist/types/components/snk-application/errorhandler/snk-error-handler.d.ts +1 -1
  61. package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +21 -1
  62. package/package.json +1 -1
  63. package/dist/sankhyablocks/p-374af3cb.entry.js +0 -1
  64. package/dist/sankhyablocks/p-7e475a6f.js +0 -1
@@ -1,4 +1,4 @@
1
- import { ErrorException, ObjectUtils, WarningException } from '@sankhyalabs/core';
1
+ import { ApplicationContext, ErrorException, ObjectUtils, WarningException } from '@sankhyalabs/core';
2
2
  import { batchRequests } from 'graphql-request';
3
3
  import UrlUtils from "../../../lib/utils/urlutils";
4
4
  import { StringUtils } from '@sankhyalabs/core';
@@ -21,6 +21,7 @@ export class DataFetcher {
21
21
  application.addEventListener('applicationLoaded', () => DataFetcher.instance.resume());
22
22
  }
23
23
  }
24
+ this.instance.application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
24
25
  return this.instance;
25
26
  }
26
27
  static addRequestListener(listener) {
@@ -35,7 +36,7 @@ export class DataFetcher {
35
36
  DataFetcher.requestListener.splice(index, 1);
36
37
  }
37
38
  }
38
- processErrorInfo(errors) {
39
+ processGraphQlErrorInfo(errors) {
39
40
  var _a, _b;
40
41
  const POSITION_ERROR_INFO = 0;
41
42
  const errorTitle = "Falha detectada";
@@ -56,6 +57,22 @@ export class DataFetcher {
56
57
  return new ErrorException(errorTitle, "Não há informações sobre o erro");
57
58
  }
58
59
  }
60
+ processServiceBrokerErrorInfo(serviceBrokerResponse) {
61
+ const title = "Falha detectada";
62
+ let { statusMessage, tsError } = serviceBrokerResponse || {};
63
+ if (!statusMessage) {
64
+ statusMessage = "Não há informações sobre o erro";
65
+ }
66
+ let tsErrorCode, tsErrorLevel;
67
+ if (tsError) {
68
+ tsErrorCode = tsError.tsErrorCode;
69
+ tsErrorLevel = tsError.tsErrorLevel;
70
+ }
71
+ if (tsErrorLevel === "WARNING") {
72
+ return new WarningException(title, statusMessage, tsErrorCode);
73
+ }
74
+ return new ErrorException(title, statusMessage, tsErrorCode);
75
+ }
59
76
  async callGraphQL(req) {
60
77
  var _a;
61
78
  const reqKey = this.getReqKey(req);
@@ -67,7 +84,7 @@ export class DataFetcher {
67
84
  const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
68
85
  if (res.errors.length > 0) {
69
86
  if (!this.proccesGraphQLClientEvents(res === null || res === void 0 ? void 0 : res.extensions, req, resolve, reject)) {
70
- const error = this.processErrorInfo(res.errors);
87
+ const error = this.processGraphQlErrorInfo(res.errors);
71
88
  reject(error);
72
89
  }
73
90
  }
@@ -109,6 +126,19 @@ export class DataFetcher {
109
126
  }
110
127
  return false;
111
128
  }
129
+ proccessServiceBorkerClientEvents(clientEvents, serviceName, payloadJson, accept, reject) {
130
+ if (!(clientEvents === null || clientEvents === void 0 ? void 0 : clientEvents.length)) {
131
+ return;
132
+ }
133
+ clientEvents.forEach(clientEvent => {
134
+ if (DataFetcher.hasClientEvent(clientEvent.id)) {
135
+ var handlers = DataFetcher.clientEventsByID.get(clientEvent.id);
136
+ handlers.forEach(handler => {
137
+ handler({ id: clientEvent.id, content: clientEvent }, new ServiceBrokerRecaller(serviceName, payloadJson, accept, reject));
138
+ });
139
+ }
140
+ });
141
+ }
112
142
  getContext(module) {
113
143
  var _a;
114
144
  const urlParams = UrlUtils.getQueryParams(location.search);
@@ -150,42 +180,42 @@ export class DataFetcher {
150
180
  http.open("POST", url, true);
151
181
  http.withCredentials = true;
152
182
  http.send(ObjectUtils.objectToString(payloadJson));
153
- http.onreadystatechange = function () {
154
- if (this.readyState == 4 && this.status == 200) {
183
+ http.onreadystatechange = () => {
184
+ var _a;
185
+ if (http.readyState == 4 && http.status == 200) {
155
186
  try {
156
- const jsonResp = JSON.parse(this.responseText);
157
- if (jsonResp.hasOwnProperty('clientEvents')) {
158
- jsonResp.clientEvents.forEach(clientEvent => {
159
- if (DataFetcher.hasClientEvent(clientEvent.id)) {
160
- var handlers = DataFetcher.clientEventsByID.get(clientEvent.id);
161
- handlers.forEach(handler => {
162
- handler({ id: clientEvent.id, content: clientEvent }, new ServiceBrokerRecaller(serviceName, payloadJson, accept, reject));
163
- });
164
- }
165
- });
166
- if (jsonResp.status == 4)
167
- return;
187
+ const jsonResp = JSON.parse(http.responseText);
188
+ if (this.isServiceBrokerError(jsonResp)) {
189
+ reject(this.processServiceBrokerErrorInfo(jsonResp));
168
190
  }
169
- if (jsonResp.status == 1) {
170
- accept(jsonResp.responseBody);
191
+ else if (jsonResp.status == DataFetcher.SERVICE_BROKER_STATUS.SERVICE_CANCELED && jsonResp.statusMessage) {
192
+ console.debug(`[DataFetcher] ${jsonResp.statusMessage}`);
171
193
  }
172
194
  else {
173
- reject(jsonResp);
195
+ accept(jsonResp.responseBody);
196
+ if (jsonResp.status == DataFetcher.SERVICE_BROKER_STATUS.INFO) {
197
+ (_a = this.application) === null || _a === void 0 ? void 0 : _a.info(jsonResp.statusMessage);
198
+ }
174
199
  }
200
+ this.proccessServiceBorkerClientEvents(jsonResp === null || jsonResp === void 0 ? void 0 : jsonResp.clientEvents, serviceName, payloadJson, accept, reject);
175
201
  }
176
- catch (e) {
177
- console.warn(`callServiceBroker error to parser response to JSON ${e}`);
178
- reject(this.responseText);
202
+ catch (err) {
203
+ console.warn(`Erro ao executar serviço: ${err}`);
204
+ reject(new ErrorException(`Erro ao executar serviço`, err));
179
205
  }
180
- DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
181
206
  }
182
- else if (this.readyState == 4 && this.status != 200) {
183
- reject(this.responseText);
184
- DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
207
+ else if (http.readyState == 4 && http.status != 200) {
208
+ reject(new ErrorException(`Erro ao executar serviço: ${serviceName}`, http.responseText));
185
209
  }
210
+ DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
186
211
  };
187
212
  });
188
213
  }
214
+ isServiceBrokerError(response) {
215
+ return !response.hasOwnProperty('status') ||
216
+ response.status == DataFetcher.SERVICE_BROKER_STATUS.ERROR ||
217
+ response.status == DataFetcher.SERVICE_BROKER_STATUS.TIMEOUT;
218
+ }
189
219
  getReqKey(req) {
190
220
  return window.btoa(StringUtils.hashCode(`${req.query}${JSON.stringify(req.values || "")}`)).replace(/=/g, "");
191
221
  }
@@ -310,6 +340,13 @@ export class DataFetcher {
310
340
  }
311
341
  DataFetcher.appTagName = "snk-application";
312
342
  DataFetcher.requestListener = [];
343
+ DataFetcher.SERVICE_BROKER_STATUS = {
344
+ ERROR: 0,
345
+ INFO: 2,
346
+ OK: 1,
347
+ TIMEOUT: 3,
348
+ SERVICE_CANCELED: 4
349
+ };
313
350
  DataFetcher.clientEventsByID = new Map();
314
351
  class WaitingRequest {
315
352
  constructor(req) {
@@ -1,4 +1,4 @@
1
- import { ErrorException, WarningException, ObjectUtils, StringUtils } from '@sankhyalabs/core';
1
+ import { ApplicationContext, ErrorException, WarningException, ObjectUtils, StringUtils } from '@sankhyalabs/core';
2
2
  import { c as createCommonjsModule, a as commonjsGlobal } from './_commonjsHelpers.js';
3
3
 
4
4
  var browserPonyfill = createCommonjsModule(function (module, exports) {
@@ -6481,6 +6481,7 @@ class DataFetcher {
6481
6481
  application.addEventListener('applicationLoaded', () => DataFetcher.instance.resume());
6482
6482
  }
6483
6483
  }
6484
+ this.instance.application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
6484
6485
  return this.instance;
6485
6486
  }
6486
6487
  static addRequestListener(listener) {
@@ -6495,7 +6496,7 @@ class DataFetcher {
6495
6496
  DataFetcher.requestListener.splice(index, 1);
6496
6497
  }
6497
6498
  }
6498
- processErrorInfo(errors) {
6499
+ processGraphQlErrorInfo(errors) {
6499
6500
  var _a, _b;
6500
6501
  const POSITION_ERROR_INFO = 0;
6501
6502
  const errorTitle = "Falha detectada";
@@ -6516,6 +6517,22 @@ class DataFetcher {
6516
6517
  return new ErrorException(errorTitle, "Não há informações sobre o erro");
6517
6518
  }
6518
6519
  }
6520
+ processServiceBrokerErrorInfo(serviceBrokerResponse) {
6521
+ const title = "Falha detectada";
6522
+ let { statusMessage, tsError } = serviceBrokerResponse || {};
6523
+ if (!statusMessage) {
6524
+ statusMessage = "Não há informações sobre o erro";
6525
+ }
6526
+ let tsErrorCode, tsErrorLevel;
6527
+ if (tsError) {
6528
+ tsErrorCode = tsError.tsErrorCode;
6529
+ tsErrorLevel = tsError.tsErrorLevel;
6530
+ }
6531
+ if (tsErrorLevel === "WARNING") {
6532
+ return new WarningException(title, statusMessage, tsErrorCode);
6533
+ }
6534
+ return new ErrorException(title, statusMessage, tsErrorCode);
6535
+ }
6519
6536
  async callGraphQL(req) {
6520
6537
  var _a;
6521
6538
  const reqKey = this.getReqKey(req);
@@ -6527,7 +6544,7 @@ class DataFetcher {
6527
6544
  const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
6528
6545
  if (res.errors.length > 0) {
6529
6546
  if (!this.proccesGraphQLClientEvents(res === null || res === void 0 ? void 0 : res.extensions, req, resolve, reject)) {
6530
- const error = this.processErrorInfo(res.errors);
6547
+ const error = this.processGraphQlErrorInfo(res.errors);
6531
6548
  reject(error);
6532
6549
  }
6533
6550
  }
@@ -6569,6 +6586,19 @@ class DataFetcher {
6569
6586
  }
6570
6587
  return false;
6571
6588
  }
6589
+ proccessServiceBorkerClientEvents(clientEvents, serviceName, payloadJson, accept, reject) {
6590
+ if (!(clientEvents === null || clientEvents === void 0 ? void 0 : clientEvents.length)) {
6591
+ return;
6592
+ }
6593
+ clientEvents.forEach(clientEvent => {
6594
+ if (DataFetcher.hasClientEvent(clientEvent.id)) {
6595
+ var handlers = DataFetcher.clientEventsByID.get(clientEvent.id);
6596
+ handlers.forEach(handler => {
6597
+ handler({ id: clientEvent.id, content: clientEvent }, new ServiceBrokerRecaller(serviceName, payloadJson, accept, reject));
6598
+ });
6599
+ }
6600
+ });
6601
+ }
6572
6602
  getContext(module) {
6573
6603
  var _a;
6574
6604
  const urlParams = UrlUtils.getQueryParams(location.search);
@@ -6610,42 +6640,42 @@ class DataFetcher {
6610
6640
  http.open("POST", url, true);
6611
6641
  http.withCredentials = true;
6612
6642
  http.send(ObjectUtils.objectToString(payloadJson));
6613
- http.onreadystatechange = function () {
6614
- if (this.readyState == 4 && this.status == 200) {
6643
+ http.onreadystatechange = () => {
6644
+ var _a;
6645
+ if (http.readyState == 4 && http.status == 200) {
6615
6646
  try {
6616
- const jsonResp = JSON.parse(this.responseText);
6617
- if (jsonResp.hasOwnProperty('clientEvents')) {
6618
- jsonResp.clientEvents.forEach(clientEvent => {
6619
- if (DataFetcher.hasClientEvent(clientEvent.id)) {
6620
- var handlers = DataFetcher.clientEventsByID.get(clientEvent.id);
6621
- handlers.forEach(handler => {
6622
- handler({ id: clientEvent.id, content: clientEvent }, new ServiceBrokerRecaller(serviceName, payloadJson, accept, reject));
6623
- });
6624
- }
6625
- });
6626
- if (jsonResp.status == 4)
6627
- return;
6647
+ const jsonResp = JSON.parse(http.responseText);
6648
+ if (this.isServiceBrokerError(jsonResp)) {
6649
+ reject(this.processServiceBrokerErrorInfo(jsonResp));
6628
6650
  }
6629
- if (jsonResp.status == 1) {
6630
- accept(jsonResp.responseBody);
6651
+ else if (jsonResp.status == DataFetcher.SERVICE_BROKER_STATUS.SERVICE_CANCELED && jsonResp.statusMessage) {
6652
+ console.debug(`[DataFetcher] ${jsonResp.statusMessage}`);
6631
6653
  }
6632
6654
  else {
6633
- reject(jsonResp);
6655
+ accept(jsonResp.responseBody);
6656
+ if (jsonResp.status == DataFetcher.SERVICE_BROKER_STATUS.INFO) {
6657
+ (_a = this.application) === null || _a === void 0 ? void 0 : _a.info(jsonResp.statusMessage);
6658
+ }
6634
6659
  }
6660
+ this.proccessServiceBorkerClientEvents(jsonResp === null || jsonResp === void 0 ? void 0 : jsonResp.clientEvents, serviceName, payloadJson, accept, reject);
6635
6661
  }
6636
- catch (e) {
6637
- console.warn(`callServiceBroker error to parser response to JSON ${e}`);
6638
- reject(this.responseText);
6662
+ catch (err) {
6663
+ console.warn(`Erro ao executar serviço: ${err}`);
6664
+ reject(new ErrorException(`Erro ao executar serviço`, err));
6639
6665
  }
6640
- DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
6641
6666
  }
6642
- else if (this.readyState == 4 && this.status != 200) {
6643
- reject(this.responseText);
6644
- DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
6667
+ else if (http.readyState == 4 && http.status != 200) {
6668
+ reject(new ErrorException(`Erro ao executar serviço: ${serviceName}`, http.responseText));
6645
6669
  }
6670
+ DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
6646
6671
  };
6647
6672
  });
6648
6673
  }
6674
+ isServiceBrokerError(response) {
6675
+ return !response.hasOwnProperty('status') ||
6676
+ response.status == DataFetcher.SERVICE_BROKER_STATUS.ERROR ||
6677
+ response.status == DataFetcher.SERVICE_BROKER_STATUS.TIMEOUT;
6678
+ }
6649
6679
  getReqKey(req) {
6650
6680
  return window.btoa(StringUtils.hashCode(`${req.query}${JSON.stringify(req.values || "")}`)).replace(/=/g, "");
6651
6681
  }
@@ -6770,6 +6800,13 @@ class DataFetcher {
6770
6800
  }
6771
6801
  DataFetcher.appTagName = "snk-application";
6772
6802
  DataFetcher.requestListener = [];
6803
+ DataFetcher.SERVICE_BROKER_STATUS = {
6804
+ ERROR: 0,
6805
+ INFO: 2,
6806
+ OK: 1,
6807
+ TIMEOUT: 3,
6808
+ SERVICE_CANCELED: 4
6809
+ };
6773
6810
  DataFetcher.clientEventsByID = new Map();
6774
6811
  class WaitingRequest {
6775
6812
  constructor(req) {
@@ -34,13 +34,13 @@ class SnkErrorHandler {
34
34
  errorHandler(evt) {
35
35
  this.processException(evt.error);
36
36
  }
37
- buildErrorCodeHTML(exception) {
38
- const onclick = 'try{window.workspace.openHelp(\'_tbcode:' + exception.errorCode + '\')} catch(e){alert(\'Não é possível abrir a ajuda fora do workspace Sankhya\');}';
39
- return '<br><a href="#" onclick="' + onclick + '">Código: ' + exception.errorCode + '</a>';
37
+ buildErrorCodeHTML(errorCode) {
38
+ const onclick = 'try{window.workspace.openHelp(\'_tbcode:' + errorCode + '\')} catch(e){alert(\'Não é possível abrir a ajuda fora do workspace Sankhya\');}';
39
+ return '<br><a href="#" onclick="' + onclick + '">Código: ' + errorCode + '</a>';
40
40
  }
41
41
  processException(exception) {
42
42
  if (exception.errorCode) {
43
- exception.message += this.buildErrorCodeHTML(exception);
43
+ exception.message += this.buildErrorCodeHTML(exception.errorCode);
44
44
  }
45
45
  if (exception instanceof WaitingChangeException) {
46
46
  this._app.alert(exception.title, exception.message);
@@ -260,11 +260,12 @@ const SnkSimpleCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
260
260
  this.dataState = Object.assign({}, evt.detail);
261
261
  }
262
262
  getTaskBarDisabledButtons() {
263
+ var _a, _b;
263
264
  const disabledButtons = [];
264
- if (!this.dataState.hasNext) {
265
+ if (!((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.hasNext)) {
265
266
  disabledButtons.push(TaskbarElement.NEXT);
266
267
  }
267
- if (!this.dataState.hasPrevious) {
268
+ if (!((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.hasPrevious)) {
268
269
  disabledButtons.push(TaskbarElement.PREVIOUS);
269
270
  }
270
271
  return disabledButtons;
@@ -1,5 +1,5 @@
1
1
  import { ApplicationContext } from '@sankhyalabs/core';
2
- import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-74e3e14b.js';
2
+ import { R as ResourceFetcher, F as FormConfigFetcher } from './form-config-fetcher-018e7e73.js';
3
3
 
4
4
  class GridConfigFetcher extends ResourceFetcher {
5
5
  constructor() {
@@ -1,4 +1,4 @@
1
- import { ErrorException, WarningException, ObjectUtils, StringUtils } from '@sankhyalabs/core';
1
+ import { ApplicationContext, ErrorException, WarningException, ObjectUtils, StringUtils } from '@sankhyalabs/core';
2
2
  import { c as createCommonjsModule, a as commonjsGlobal } from './_commonjsHelpers-9943807e.js';
3
3
 
4
4
  var browserPonyfill = createCommonjsModule(function (module, exports) {
@@ -6481,6 +6481,7 @@ class DataFetcher {
6481
6481
  application.addEventListener('applicationLoaded', () => DataFetcher.instance.resume());
6482
6482
  }
6483
6483
  }
6484
+ this.instance.application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
6484
6485
  return this.instance;
6485
6486
  }
6486
6487
  static addRequestListener(listener) {
@@ -6495,7 +6496,7 @@ class DataFetcher {
6495
6496
  DataFetcher.requestListener.splice(index, 1);
6496
6497
  }
6497
6498
  }
6498
- processErrorInfo(errors) {
6499
+ processGraphQlErrorInfo(errors) {
6499
6500
  var _a, _b;
6500
6501
  const POSITION_ERROR_INFO = 0;
6501
6502
  const errorTitle = "Falha detectada";
@@ -6516,6 +6517,22 @@ class DataFetcher {
6516
6517
  return new ErrorException(errorTitle, "Não há informações sobre o erro");
6517
6518
  }
6518
6519
  }
6520
+ processServiceBrokerErrorInfo(serviceBrokerResponse) {
6521
+ const title = "Falha detectada";
6522
+ let { statusMessage, tsError } = serviceBrokerResponse || {};
6523
+ if (!statusMessage) {
6524
+ statusMessage = "Não há informações sobre o erro";
6525
+ }
6526
+ let tsErrorCode, tsErrorLevel;
6527
+ if (tsError) {
6528
+ tsErrorCode = tsError.tsErrorCode;
6529
+ tsErrorLevel = tsError.tsErrorLevel;
6530
+ }
6531
+ if (tsErrorLevel === "WARNING") {
6532
+ return new WarningException(title, statusMessage, tsErrorCode);
6533
+ }
6534
+ return new ErrorException(title, statusMessage, tsErrorCode);
6535
+ }
6519
6536
  async callGraphQL(req) {
6520
6537
  var _a;
6521
6538
  const reqKey = this.getReqKey(req);
@@ -6527,7 +6544,7 @@ class DataFetcher {
6527
6544
  const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
6528
6545
  if (res.errors.length > 0) {
6529
6546
  if (!this.proccesGraphQLClientEvents(res === null || res === void 0 ? void 0 : res.extensions, req, resolve, reject)) {
6530
- const error = this.processErrorInfo(res.errors);
6547
+ const error = this.processGraphQlErrorInfo(res.errors);
6531
6548
  reject(error);
6532
6549
  }
6533
6550
  }
@@ -6569,6 +6586,19 @@ class DataFetcher {
6569
6586
  }
6570
6587
  return false;
6571
6588
  }
6589
+ proccessServiceBorkerClientEvents(clientEvents, serviceName, payloadJson, accept, reject) {
6590
+ if (!(clientEvents === null || clientEvents === void 0 ? void 0 : clientEvents.length)) {
6591
+ return;
6592
+ }
6593
+ clientEvents.forEach(clientEvent => {
6594
+ if (DataFetcher.hasClientEvent(clientEvent.id)) {
6595
+ var handlers = DataFetcher.clientEventsByID.get(clientEvent.id);
6596
+ handlers.forEach(handler => {
6597
+ handler({ id: clientEvent.id, content: clientEvent }, new ServiceBrokerRecaller(serviceName, payloadJson, accept, reject));
6598
+ });
6599
+ }
6600
+ });
6601
+ }
6572
6602
  getContext(module) {
6573
6603
  var _a;
6574
6604
  const urlParams = UrlUtils.getQueryParams(location.search);
@@ -6610,42 +6640,42 @@ class DataFetcher {
6610
6640
  http.open("POST", url, true);
6611
6641
  http.withCredentials = true;
6612
6642
  http.send(ObjectUtils.objectToString(payloadJson));
6613
- http.onreadystatechange = function () {
6614
- if (this.readyState == 4 && this.status == 200) {
6643
+ http.onreadystatechange = () => {
6644
+ var _a;
6645
+ if (http.readyState == 4 && http.status == 200) {
6615
6646
  try {
6616
- const jsonResp = JSON.parse(this.responseText);
6617
- if (jsonResp.hasOwnProperty('clientEvents')) {
6618
- jsonResp.clientEvents.forEach(clientEvent => {
6619
- if (DataFetcher.hasClientEvent(clientEvent.id)) {
6620
- var handlers = DataFetcher.clientEventsByID.get(clientEvent.id);
6621
- handlers.forEach(handler => {
6622
- handler({ id: clientEvent.id, content: clientEvent }, new ServiceBrokerRecaller(serviceName, payloadJson, accept, reject));
6623
- });
6624
- }
6625
- });
6626
- if (jsonResp.status == 4)
6627
- return;
6647
+ const jsonResp = JSON.parse(http.responseText);
6648
+ if (this.isServiceBrokerError(jsonResp)) {
6649
+ reject(this.processServiceBrokerErrorInfo(jsonResp));
6628
6650
  }
6629
- if (jsonResp.status == 1) {
6630
- accept(jsonResp.responseBody);
6651
+ else if (jsonResp.status == DataFetcher.SERVICE_BROKER_STATUS.SERVICE_CANCELED && jsonResp.statusMessage) {
6652
+ console.debug(`[DataFetcher] ${jsonResp.statusMessage}`);
6631
6653
  }
6632
6654
  else {
6633
- reject(jsonResp);
6655
+ accept(jsonResp.responseBody);
6656
+ if (jsonResp.status == DataFetcher.SERVICE_BROKER_STATUS.INFO) {
6657
+ (_a = this.application) === null || _a === void 0 ? void 0 : _a.info(jsonResp.statusMessage);
6658
+ }
6634
6659
  }
6660
+ this.proccessServiceBorkerClientEvents(jsonResp === null || jsonResp === void 0 ? void 0 : jsonResp.clientEvents, serviceName, payloadJson, accept, reject);
6635
6661
  }
6636
- catch (e) {
6637
- console.warn(`callServiceBroker error to parser response to JSON ${e}`);
6638
- reject(this.responseText);
6662
+ catch (err) {
6663
+ console.warn(`Erro ao executar serviço: ${err}`);
6664
+ reject(new ErrorException(`Erro ao executar serviço`, err));
6639
6665
  }
6640
- DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
6641
6666
  }
6642
- else if (this.readyState == 4 && this.status != 200) {
6643
- reject(this.responseText);
6644
- DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
6667
+ else if (http.readyState == 4 && http.status != 200) {
6668
+ reject(new ErrorException(`Erro ao executar serviço: ${serviceName}`, http.responseText));
6645
6669
  }
6670
+ DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
6646
6671
  };
6647
6672
  });
6648
6673
  }
6674
+ isServiceBrokerError(response) {
6675
+ return !response.hasOwnProperty('status') ||
6676
+ response.status == DataFetcher.SERVICE_BROKER_STATUS.ERROR ||
6677
+ response.status == DataFetcher.SERVICE_BROKER_STATUS.TIMEOUT;
6678
+ }
6649
6679
  getReqKey(req) {
6650
6680
  return window.btoa(StringUtils.hashCode(`${req.query}${JSON.stringify(req.values || "")}`)).replace(/=/g, "");
6651
6681
  }
@@ -6770,6 +6800,13 @@ class DataFetcher {
6770
6800
  }
6771
6801
  DataFetcher.appTagName = "snk-application";
6772
6802
  DataFetcher.requestListener = [];
6803
+ DataFetcher.SERVICE_BROKER_STATUS = {
6804
+ ERROR: 0,
6805
+ INFO: 2,
6806
+ OK: 1,
6807
+ TIMEOUT: 3,
6808
+ SERVICE_CANCELED: 4
6809
+ };
6773
6810
  DataFetcher.clientEventsByID = new Map();
6774
6811
  class WaitingRequest {
6775
6812
  constructor(req) {
@@ -1,6 +1,6 @@
1
- import { C as ConfigStorage } from './ConfigStorage-479e3228.js';
1
+ import { C as ConfigStorage } from './ConfigStorage-ac77ff39.js';
2
2
  import { ObjectUtils } from '@sankhyalabs/core';
3
- import { F as FormConfigFetcher } from './form-config-fetcher-74e3e14b.js';
3
+ import { F as FormConfigFetcher } from './form-config-fetcher-018e7e73.js';
4
4
 
5
5
  class SnkFormConfigManager {
6
6
  constructor(configName, onConfigChange) {
@@ -1,4 +1,4 @@
1
- import { d as dist, D as DataFetcher } from './DataFetcher-caa61f2c.js';
1
+ import { d as dist, D as DataFetcher } from './DataFetcher-b3d8b2d5.js';
2
2
  import { ObjectUtils } from '@sankhyalabs/core';
3
3
 
4
4
  class ResourceFetcher {
@@ -1,5 +1,5 @@
1
1
  import { DataType } from '@sankhyalabs/core';
2
- import { d as dist, D as DataFetcher } from './DataFetcher-caa61f2c.js';
2
+ import { d as dist, D as DataFetcher } from './DataFetcher-b3d8b2d5.js';
3
3
 
4
4
  class PesquisaFetcher {
5
5
  constructor() {
@@ -1,10 +1,10 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement } from './index-cfd4bb13.js';
2
2
  import { WaitingChangeException, WarningException, ErrorException, ObjectUtils, DataUnit, StringUtils, DataType, DataUnitStorage, ChangeOperation, DateUtils, DependencyType, ElementIDUtils, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
3
- import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher-caa61f2c.js';
3
+ import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher-b3d8b2d5.js';
4
4
  import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
5
- import { P as PesquisaFetcher } from './pesquisa-fetcher-c86787c1.js';
6
- import { G as GridConfigFetcher, C as ConfigStorage } from './ConfigStorage-479e3228.js';
7
- import { R as ResourceFetcher } from './form-config-fetcher-74e3e14b.js';
5
+ import { P as PesquisaFetcher } from './pesquisa-fetcher-bd6af0e3.js';
6
+ import { G as GridConfigFetcher, C as ConfigStorage } from './ConfigStorage-ac77ff39.js';
7
+ import { R as ResourceFetcher } from './form-config-fetcher-018e7e73.js';
8
8
  import { S as SnkMessageBuilder } from './SnkMessageBuilder-68bbf0ae.js';
9
9
  import './_commonjsHelpers-9943807e.js';
10
10
 
@@ -34,13 +34,13 @@ class SnkErrorHandler {
34
34
  errorHandler(evt) {
35
35
  this.processException(evt.error);
36
36
  }
37
- buildErrorCodeHTML(exception) {
38
- const onclick = 'try{window.workspace.openHelp(\'_tbcode:' + exception.errorCode + '\')} catch(e){alert(\'Não é possível abrir a ajuda fora do workspace Sankhya\');}';
39
- return '<br><a href="#" onclick="' + onclick + '">Código: ' + exception.errorCode + '</a>';
37
+ buildErrorCodeHTML(errorCode) {
38
+ const onclick = 'try{window.workspace.openHelp(\'_tbcode:' + errorCode + '\')} catch(e){alert(\'Não é possível abrir a ajuda fora do workspace Sankhya\');}';
39
+ return '<br><a href="#" onclick="' + onclick + '">Código: ' + errorCode + '</a>';
40
40
  }
41
41
  processException(exception) {
42
42
  if (exception.errorCode) {
43
- exception.message += this.buildErrorCodeHTML(exception);
43
+ exception.message += this.buildErrorCodeHTML(exception.errorCode);
44
44
  }
45
45
  if (exception instanceof WaitingChangeException) {
46
46
  this._app.alert(exception.title, exception.message);
@@ -1,8 +1,8 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement } from './index-cfd4bb13.js';
2
2
  import { ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { T as TaskbarElement } from './taskbar-elements-10d80c79.js';
4
- import './DataFetcher-caa61f2c.js';
5
- import './pesquisa-fetcher-c86787c1.js';
4
+ import './DataFetcher-b3d8b2d5.js';
5
+ import './pesquisa-fetcher-bd6af0e3.js';
6
6
  import { P as PresentationMode } from './index-6519a79e.js';
7
7
  import { c as VIEW_MODE } from './constants-15617e7d.js';
8
8
  import './index-e467ade5.js';
@@ -3,7 +3,7 @@ import { ObjectUtils, ApplicationContext, ElementIDUtils } from '@sankhyalabs/co
3
3
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
4
4
  import { D as DataExporterOption, a as DataExporterFormat, b as DataExporterType } from './index-6519a79e.js';
5
5
  import { d as KEY_PORT_EXPORT, W as WEB_CONNECTION, R as REPORT_LAUNCHER_RESOURCE_ID } from './constants-15617e7d.js';
6
- import { D as DataFetcher } from './DataFetcher-caa61f2c.js';
6
+ import { D as DataFetcher } from './DataFetcher-b3d8b2d5.js';
7
7
  import { S as SnkDataUnit } from './snk-data-unit-a8093f95.js';
8
8
  import './_commonjsHelpers-9943807e.js';
9
9
  import './SnkMessageBuilder-68bbf0ae.js';
@@ -1,16 +1,16 @@
1
1
  import { r as registerInstance, c as createEvent, f as forceUpdate, h, H as Host } from './index-cfd4bb13.js';
2
- import { S as SnkFormConfigManager } from './SnkFormConfigManager-960d808d.js';
2
+ import { S as SnkFormConfigManager } from './SnkFormConfigManager-40609500.js';
3
3
  import { FormMetadata, buildFormMetadata } from '@sankhyalabs/ezui/dist/collection/utils/form';
4
- import './DataFetcher-caa61f2c.js';
5
- import './pesquisa-fetcher-c86787c1.js';
4
+ import './DataFetcher-b3d8b2d5.js';
5
+ import './pesquisa-fetcher-bd6af0e3.js';
6
6
  import '@sankhyalabs/core';
7
7
  import { P as PresentationMode } from './index-6519a79e.js';
8
8
  import { T as TaskbarElement } from './taskbar-elements-10d80c79.js';
9
9
  import { c as VIEW_MODE } from './constants-15617e7d.js';
10
- import { S as SnkGuidesViewer } from './snk-guides-viewer-c9e5aa60.js';
10
+ import { S as SnkGuidesViewer } from './snk-guides-viewer-1e7c21f6.js';
11
11
  import { S as SnkMessageBuilder } from './SnkMessageBuilder-68bbf0ae.js';
12
- import './ConfigStorage-479e3228.js';
13
- import './form-config-fetcher-74e3e14b.js';
12
+ import './ConfigStorage-ac77ff39.js';
13
+ import './form-config-fetcher-018e7e73.js';
14
14
  import './_commonjsHelpers-9943807e.js';
15
15
  import './index-e467ade5.js';
16
16
  import './taskbar-processor-94402e6e.js';
@@ -4,9 +4,9 @@ import { EzScrollDirection } from '@sankhyalabs/ezui/dist/collection/components/
4
4
  import { F as FilterItemType } from './filter-item-type.enum-a79b2fa8.js';
5
5
  import { ModalAction } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
6
6
  import { toString } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
7
- import { C as ConfigStorage } from './ConfigStorage-479e3228.js';
8
- import './form-config-fetcher-74e3e14b.js';
9
- import './DataFetcher-caa61f2c.js';
7
+ import { C as ConfigStorage } from './ConfigStorage-ac77ff39.js';
8
+ import './form-config-fetcher-018e7e73.js';
9
+ import './DataFetcher-b3d8b2d5.js';
10
10
  import './_commonjsHelpers-9943807e.js';
11
11
 
12
12
  const buildFilter = (item) => {
@@ -3,10 +3,10 @@ import { d as draggable_bundle } from './draggable.bundle-41d56f06.js';
3
3
  import { ObjectUtils, ElementIDUtils, ArrayUtils, ApplicationContext } from '@sankhyalabs/core';
4
4
  import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
5
5
  import { C as CONFIG_EVENTS, T as TAB_NAMES, A as ACTION_CONFIG, D as DEFAULT_TYPE } from './constants-15617e7d.js';
6
- import { U as UserConfigType } from './form-config-fetcher-74e3e14b.js';
6
+ import { U as UserConfigType } from './form-config-fetcher-018e7e73.js';
7
7
  import { buildFormConfigFromDataUnit } from '@sankhyalabs/ezui/dist/collection/utils/form';
8
8
  import './_commonjsHelpers-9943807e.js';
9
- import './DataFetcher-caa61f2c.js';
9
+ import './DataFetcher-b3d8b2d5.js';
10
10
 
11
11
  const snkFormConfigCss = ".sc-snk-form-config-h{--snk-form-config--z-index:var(--more-visible, 2);--snk-form-config--background-color:var(--background--xlight, #fff);--snk-form-config__icon--color:var(--text--disable, #AFB6C0);--snk-form-config__label-counter--font-weight:var(--text-weight--extra-small, 200);--snk-form-config__add-group-container--border-radius:var(--border--radius-medium, 12px);--snk-form-config__add-group-container--background-color:var(--background--medium, #d2dce9);--snk-form-config__add-group-container--padding:var(--space--small, 6px);--snk-form-config__add-group-content--border:2px dashed var(--color-strokes, #DCE0E8);--snk-form-config__add-group-content--border-radius:var(--border--radius-small, 6px);--snk-form-config__add-group-label--padding:var(--space--large, 24px);--snk-form-config__btn-add-group--padding:var(--space--large, 24px) var(--space--medium, 12px) 0;--snk-form-config__btn-add-group-container--padding:var(--space--medium, 12px);--snk-form-config__btn-add-group-container--border-radius:var(--border--radius-medium, 12px);--snk-form-config__btn-add-group-container--border:2px solid var(--color-strokes, #DCE0E8);--snk-form-config__btn-add-group-container--background-color:var(--background--body, #fafcff);display:flex;flex-direction:column;position:fixed;top:0;left:0;width:100%;height:100%;z-index:var(--snk-form-config--z-index);background-color:var(--snk-form-config--background-color)}.form-config__header-container.sc-snk-form-config{display:flex}.form-config__field-container.sc-snk-form-config{width:32%;padding:6px}.form-config__hide-content.sc-snk-form-config{display:none}ez-icon.sc-snk-form-config .left-icon.sc-snk-form-config{--ez-icon--color:var(--snk-form-config__icon--color)}.ez-box__label-counter.sc-snk-form-config{margin-top:-7px;font-weight:var(--snk-form-config__label-counter--font-weight)}.form-config__btn-options.sc-snk-form-config{--ez-button--min-width:300px;--ez-button--background-color:var(--snk-form-config--background-color)}[data-draggable-parent].sc-snk-form-config{position:relative}.form-config__field-config--selected.sc-snk-form-config{position:static}.form-config__field-config--dragged.sc-snk-form-config .draggable-mirror.sc-snk-form-config{z-index:var(--snk-form-config--z-index)}.form-config__config-options.sc-snk-form-config{position:relative;margin-top:-3px;min-width:100%;z-index:1}.form-config__tab-container.sc-snk-form-config,.form-config__fields-available.sc-snk-form-config{position:relative;height:100%;max-height:calc(100vh - 92px)}.form-config__tab-container.sc-snk-form-config .ez-box__container.sc-snk-form-config,.form-config__fields-available.sc-snk-form-config .ez-box__container.sc-snk-form-config{align-content:flex-start;height:100%}.form-config__fields-available.sc-snk-form-config [data-draggable-parent].sc-snk-form-config{align-content:flex-start;overflow-y:auto;height:100%;max-height:calc(100% - 122px)}.form-config__tab-content.sc-snk-form-config{align-content:flex-start;overflow-y:auto;height:auto;max-height:calc(100% - 128px)}[data-draggable-element].sc-snk-form-config{cursor:grab}.form-config__actions-button.sc-snk-form-config{--ez-actions-button__btn-action--min-width:235px}.form-config__add-group.sc-snk-form-config{position:relative;min-height:120px;margin-bottom:10px}.form-config__add-group-container.sc-snk-form-config{position:absolute;display:flex;flex-wrap:wrap;width:100%;box-sizing:border-box;border-radius:var(--snk-form-config__add-group-container--border-radius);background-color:var(--snk-form-config__add-group-container--background-color);padding:var(--snk-form-config__add-group-container--padding)}.form-config__add-group-content.sc-snk-form-config{width:100%;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;box-sizing:border-box;border:var(--snk-form-config__add-group-content--border);border-radius:var(--snk-form-config__add-group-content--border-radius)}.form-config__add-group-label.sc-snk-form-config{display:flex;justify-content:center;box-sizing:border-box;padding:var(--snk-form-config__add-group-label--padding)}.form-config__btn-add-group.sc-snk-form-config{position:relative;padding:var(--snk-form-config__btn-add-group--padding)}.form-config__btn-add-group-container.sc-snk-form-config{padding:var(--snk-form-config__btn-add-group-container--padding);border-radius:var(--snk-form-config__btn-add-group-container--border-radius);border:var(--snk-form-config__btn-add-group-container--border);background-color:var(--snk-form-config__btn-add-group-container--background-color)}ez-collapsible-box.draggable-mirror.sc-snk-form-config{display:table;background-color:var(--snk-form-config--background-color)}ez-collapsible-box.sc-snk-form-config{margin-bottom:10px}@media screen and (min-width: 480px){.form-config__field-config--selected.sc-snk-form-config .ez-flex.form-config__config-options.sc-snk-form-config{min-width:calc(300% + 12px)}.form-config__field-config--selected.sc-snk-form-config:nth-child(3n+2) .ez-flex.form-config__config-options.sc-snk-form-config{transform:translate(calc(100% / 3 * -1))}.form-config__field-config--selected.sc-snk-form-config:nth-child(3n+3) .ez-flex.form-config__config-options.sc-snk-form-config{transform:translate(calc(100% / 3 * -2))}}";
12
12