@fluxhub/fluxhub-lib 22.0.4 → 22.0.5

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.
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, EventEmitter, Output, Input, ChangeDetectionStrategy, Component, ViewChild, Inject, forwardRef, Optional, Pipe, HostListener, Directive, ViewEncapsulation, ViewContainerRef, ElementRef, ViewChildren, HostBinding } from '@angular/core';
2
+ import { Injectable, InjectionToken, inject, EventEmitter, Output, Input, ChangeDetectionStrategy, Component, ViewChild, Inject, forwardRef, Optional, Pipe, HostListener, Directive, ViewEncapsulation, ViewContainerRef, ElementRef, ViewChildren, HostBinding } from '@angular/core';
3
3
  import * as i1$1 from '@angular/common/http';
4
- import { HttpHeaders, HttpEventType, HttpErrorResponse } from '@angular/common/http';
4
+ import { HttpHeaders, HttpErrorResponse, HttpEventType } from '@angular/common/http';
5
5
  import { map, catchError, flatMap, debounceTime, switchMap, filter, take, tap } from 'rxjs/operators';
6
6
  import * as i3$1 from 'ngx-toastr';
7
7
  import * as i3$2 from '@angular/router';
@@ -1564,12 +1564,83 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
1564
1564
  }]
1565
1565
  }], ctorParameters: () => [{ type: i3$1.ToastrService }, { type: i1$1.HttpClient }, { type: i3$2.Router }, { type: AppService }, { type: UtilityService }] });
1566
1566
 
1567
+ /** Fornito dal portale: `{ provide: FH_ERROR_REPORTER, useValue: (r) => ... }` */
1568
+ const FH_ERROR_REPORTER = new InjectionToken('FH_ERROR_REPORTER');
1569
+ /** Header con cui il server dichiara di aver gia' registrato l'errore. */
1570
+ const FH_EVENT_ID_HEADER = 'X-FH-Event-Id';
1571
+ /** Header con la pagina del portale, letto dal server per arricchire i suoi eventi. */
1572
+ const FH_ROUTE_HEADER = 'X-FH-Route';
1573
+ /** Pagina corrente: i portali usano l'hash routing (/#/home), altrimenti il path. */
1574
+ function fhCurrentRoute() {
1575
+ try {
1576
+ const h = window.location.hash || '';
1577
+ const r = h.startsWith('#') ? h.substring(1) : window.location.pathname;
1578
+ // Va in un header HTTP: solo ASCII stampabile, il resto codificato.
1579
+ return (r.split('?')[0] || '/')
1580
+ .substring(0, 200)
1581
+ .replace(/[^\x20-\x7E]/g, (c) => encodeURIComponent(c));
1582
+ }
1583
+ catch {
1584
+ return '';
1585
+ }
1586
+ }
1587
+ function fhEndpointOf(url) {
1588
+ if (!url)
1589
+ return '';
1590
+ try {
1591
+ // Solo l'ultimo segmento (/doquery, /dogridn): il prefisso del reverse proxy
1592
+ // (/fh3/...) cambia da portale a portale e il backend non lo vede.
1593
+ const segs = new URL(url, window.location.href).pathname.split('/').filter((x) => x);
1594
+ return '/' + (segs[segs.length - 1] || '');
1595
+ }
1596
+ catch {
1597
+ return url;
1598
+ }
1599
+ }
1600
+ /** Invoca il reporter senza mai far fallire la chiamata dati per colpa sua. */
1601
+ function fhReport(reporter, r) {
1602
+ if (!reporter || !r)
1603
+ return;
1604
+ try {
1605
+ reporter(r);
1606
+ }
1607
+ catch {
1608
+ // il monitoraggio non deve mai rompere il portale
1609
+ }
1610
+ }
1611
+ /** Report per un errore di trasporto, o null se non va segnalato. */
1612
+ function fhHttpErrorReport(err, base) {
1613
+ if (!(err instanceof HttpErrorResponse))
1614
+ return null;
1615
+ // 401 lo gestisce l'interceptor (refresh token); 0 e' rete assente o richiesta
1616
+ // interrotta dal cambio pagina: rumore. Si segnalano gli errori del server.
1617
+ if (err.status < 500)
1618
+ return null;
1619
+ return {
1620
+ ...base,
1621
+ kind: 'http',
1622
+ status: err.status,
1623
+ message: `${err.status} ${err.statusText || ''}`.trim(),
1624
+ serverEventId: fhEventId(err.headers),
1625
+ };
1626
+ }
1627
+ function fhEventId(h) {
1628
+ try {
1629
+ return h?.get(FH_EVENT_ID_HEADER) || null;
1630
+ }
1631
+ catch {
1632
+ return null;
1633
+ }
1634
+ }
1635
+
1567
1636
  class QueryService {
1568
1637
  http;
1569
1638
  toastr;
1570
1639
  app_s;
1571
1640
  uti_s;
1572
1641
  headers;
1642
+ // Opzionale: lo fornisce il portale che raccoglie gli errori (vedi error-reporter.ts)
1643
+ reporter = inject(FH_ERROR_REPORTER, { optional: true });
1573
1644
  url = null;
1574
1645
  constructor(http, toastr, app_s, uti_s) {
1575
1646
  this.http = http;
@@ -1594,6 +1665,7 @@ class QueryService {
1594
1665
  this.headers = new HttpHeaders({
1595
1666
  "Content-Type": "application/json",
1596
1667
  Authorization: "Bearer " + localStorage.getItem(this.app_s.COMPANY_KEY + "token"),
1668
+ [FH_ROUTE_HEADER]: fhCurrentRoute(),
1597
1669
  });
1598
1670
  if (url_sec == null)
1599
1671
  this.url = this.app_s.API_ENDPOINT + this.app_s.QUERY_ENDPOINT;
@@ -1651,7 +1723,15 @@ class QueryService {
1651
1723
  // se rilevo che sono sono localhost:4200 scrivo su console
1652
1724
  if (isLocalhost) {
1653
1725
  }
1654
- return this.http.post(this.url, post_v, { headers: this.headers }).pipe(map((res) => {
1726
+ const base = {
1727
+ service: "query",
1728
+ endpoint: fhEndpointOf(this.url),
1729
+ key: queryp.sql || "",
1730
+ route: fhCurrentRoute(),
1731
+ displayError,
1732
+ };
1733
+ return this.http.post(this.url, post_v, { headers: this.headers, observe: "response" }).pipe(map((resp) => {
1734
+ const res = resp?.body;
1655
1735
  this.app_s.complete();
1656
1736
  // Handle errors, display if enabled
1657
1737
  let err;
@@ -1662,6 +1742,12 @@ class QueryService {
1662
1742
  err = new Error(res.msg);
1663
1743
  }
1664
1744
  if (err) {
1745
+ fhReport(this.reporter, {
1746
+ ...base,
1747
+ kind: res ? "ko" : "empty",
1748
+ message: err.message || "",
1749
+ serverEventId: fhEventId(resp?.headers),
1750
+ });
1665
1751
  console.error(err);
1666
1752
  if (displayError) {
1667
1753
  console.error(queryp.sql + ' ' + err.message);
@@ -1681,6 +1767,7 @@ class QueryService {
1681
1767
  res.result_data = this.uti_s.convertKeysToLowerCase(res.result_data);
1682
1768
  return res || new QGResult();
1683
1769
  }), catchError((err) => {
1770
+ fhReport(this.reporter, fhHttpErrorReport(err, base));
1684
1771
  let errMsg = err.message
1685
1772
  ? err.message
1686
1773
  : err.status
@@ -10026,6 +10113,8 @@ class GridService {
10026
10113
  toastr;
10027
10114
  uti_s;
10028
10115
  headers;
10116
+ // Opzionale: lo fornisce il portale che raccoglie gli errori (vedi error-reporter.ts)
10117
+ reporter = inject(FH_ERROR_REPORTER, { optional: true });
10029
10118
  constructor(http, app_s, toastr, uti_s) {
10030
10119
  this.http = http;
10031
10120
  this.app_s = app_s;
@@ -10039,13 +10128,22 @@ class GridService {
10039
10128
  this.headers = new HttpHeaders({
10040
10129
  "Content-Type": "application/json",
10041
10130
  Authorization: "Bearer " + localStorage.getItem(this.app_s.COMPANY_KEY + "token"),
10131
+ [FH_ROUTE_HEADER]: fhCurrentRoute(),
10042
10132
  });
10043
10133
  if (url_sec == null)
10044
10134
  this.url = this.app_s.API_ENDPOINT + this.app_s.GRID_ENDPOINT;
10045
10135
  else
10046
10136
  this.url = url_sec;
10047
10137
  let post_v = JSON.stringify(queryp);
10048
- return this.http.post(this.url, post_v, { headers: this.headers }).pipe(map((res) => {
10138
+ const base = {
10139
+ service: "grid",
10140
+ endpoint: fhEndpointOf(this.url),
10141
+ key: queryp.kd || queryp.table || "",
10142
+ route: fhCurrentRoute(),
10143
+ displayError,
10144
+ };
10145
+ return this.http.post(this.url, post_v, { headers: this.headers, observe: "response" }).pipe(map((resp) => {
10146
+ const res = resp?.body;
10049
10147
  this.app_s.complete();
10050
10148
  // Handle errors, display if enabled
10051
10149
  let err;
@@ -10056,6 +10154,12 @@ class GridService {
10056
10154
  err = new Error(res.msg);
10057
10155
  }
10058
10156
  if (err) {
10157
+ fhReport(this.reporter, {
10158
+ ...base,
10159
+ kind: res ? "ko" : "empty",
10160
+ message: err.message || "",
10161
+ serverEventId: fhEventId(resp?.headers),
10162
+ });
10059
10163
  console.error(err);
10060
10164
  if (displayError) {
10061
10165
  this.toastr.error(err.message);
@@ -10068,6 +10172,7 @@ class GridService {
10068
10172
  res.result_data = this.uti_s.convertKeysToLowerCase(res.result_data);
10069
10173
  return res || new QGResult();
10070
10174
  }), catchError((err) => {
10175
+ fhReport(this.reporter, fhHttpErrorReport(err, base));
10071
10176
  // In a real world app, we might use a remote logging infrastructure
10072
10177
  // We'd also dig deeper into the error to get a better message
10073
10178
  let errMsg = err.message
@@ -43196,5 +43301,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
43196
43301
  * Generated bundle index. Do not edit.
43197
43302
  */
43198
43303
 
43199
- export { AppMakerService, AppService, ApprovaGridComponent, AuthHttpRequestInterceptor, AuthenticationService, BpmnEditorComponent, CheckboxEditorComponent, ComboBoxEditorComponent, CurrencyComponent, DialogBaseComponent, FHAiAssistantComponent, FHAiChatComponent, FHAiService, FHAutoCompleteComponent, FHCheckBoxComponent, FHColorPickerComponent, FHComboboxComponent, FHConfirmValues, FHCurrencyFormatterDirective, FHCurrencyPipe, FHDatePickerComponent, FHDateRangePickerComponent, FHFieldPickListComponent, FHFilterComboboxComponent, FHFormBuilderComponent, FHFormExecuterComponent, FHFormToolBarComponent, FHGridComponent, FHGridJSONComponent, FHGridToolBarComponent, FHGuard, FHHelpButtonComponent, FHHomeDocsComponent, FHHomeLauncherComponent, FHHomeStatsComponent, FHHomeTodoComponent, FHIconPickerComponent, FHImageViewerComponent, FHListComponent, FHLogPanelComponent, FHMailArchivedComponent, FHMailPreviewComponent, FHMultiComboboxComponent, FHNotesPanelComponent, FHNumericFieldComponent, FHPickFieldComponent, FHPickUsersComponent, FHRichTextComponent, FHRoleManagerComponent, FHTableManagerComponent, FHTextAreaComponent, FHTextInputComponent, FHTimePickerComponent, FHToolBarCustomAction, FHToolbarCommandType, FHUploadComponent, FHUploadPanelComponent, FHUploadPanelS3Component, FHUploadS3Component, FHUserFieldComponent, FHWinAppLogsComponent, FHWinAskBigTextComponent, FHWinAskButtonsComponent, FHWinAskNumberComponent, FHWinAskRichTextComponent, FHWinAskTextComponent, FHWinAutoComplete, FHWinComboComponent, FHWinConfirmComponent, FHWinErrorComponent, FHWinGridSelection, FHWinInfoComponent, FHWinListComponent, FHWinMappaComponent, FHWinOutputComponent, FHWinPicklistComponent, FHWinSalvaAnnulla, FHWinSearchListComponent, FHWinSelectByGridComponent, FHWinShowEmail, FHWinShowEmailS3, FHWinShowImage, FHWinShowLog, FHWinShowLogDett, FHWinTimeSlider, FHWinUploadComponent, FHWinUserInfo, FHWinUserPickerComponent, FHWinWaitComponent, FHWorkflowForm, FHWorkflowHeaderBar, FHWorkflowTasksPanel, FHWorkflowView, FSInput, FSResult, FileService, GridService, LocalDBService, MonthYearPickerComponent, NumericEditorComponent, OdbcService, OfficeAutomatorService, OfficeOperation, OfficeResult, QGParam, QGResult, QParam, QResult, QueryOpenService, QueryService, RegistrationService, ReplaceLineBreaks, SafePipe, TextAreaEditorComponent, UtilityService, WkfService, YearPickerComponent, createButtonCommand, createCheckboxCommand, createSpacerCommand, createTableManagerCommand, fh_win_translate, wkfField };
43304
+ export { AppMakerService, AppService, ApprovaGridComponent, AuthHttpRequestInterceptor, AuthenticationService, BpmnEditorComponent, CheckboxEditorComponent, ComboBoxEditorComponent, CurrencyComponent, DialogBaseComponent, FHAiAssistantComponent, FHAiChatComponent, FHAiService, FHAutoCompleteComponent, FHCheckBoxComponent, FHColorPickerComponent, FHComboboxComponent, FHConfirmValues, FHCurrencyFormatterDirective, FHCurrencyPipe, FHDatePickerComponent, FHDateRangePickerComponent, FHFieldPickListComponent, FHFilterComboboxComponent, FHFormBuilderComponent, FHFormExecuterComponent, FHFormToolBarComponent, FHGridComponent, FHGridJSONComponent, FHGridToolBarComponent, FHGuard, FHHelpButtonComponent, FHHomeDocsComponent, FHHomeLauncherComponent, FHHomeStatsComponent, FHHomeTodoComponent, FHIconPickerComponent, FHImageViewerComponent, FHListComponent, FHLogPanelComponent, FHMailArchivedComponent, FHMailPreviewComponent, FHMultiComboboxComponent, FHNotesPanelComponent, FHNumericFieldComponent, FHPickFieldComponent, FHPickUsersComponent, FHRichTextComponent, FHRoleManagerComponent, FHTableManagerComponent, FHTextAreaComponent, FHTextInputComponent, FHTimePickerComponent, FHToolBarCustomAction, FHToolbarCommandType, FHUploadComponent, FHUploadPanelComponent, FHUploadPanelS3Component, FHUploadS3Component, FHUserFieldComponent, FHWinAppLogsComponent, FHWinAskBigTextComponent, FHWinAskButtonsComponent, FHWinAskNumberComponent, FHWinAskRichTextComponent, FHWinAskTextComponent, FHWinAutoComplete, FHWinComboComponent, FHWinConfirmComponent, FHWinErrorComponent, FHWinGridSelection, FHWinInfoComponent, FHWinListComponent, FHWinMappaComponent, FHWinOutputComponent, FHWinPicklistComponent, FHWinSalvaAnnulla, FHWinSearchListComponent, FHWinSelectByGridComponent, FHWinShowEmail, FHWinShowEmailS3, FHWinShowImage, FHWinShowLog, FHWinShowLogDett, FHWinTimeSlider, FHWinUploadComponent, FHWinUserInfo, FHWinUserPickerComponent, FHWinWaitComponent, FHWorkflowForm, FHWorkflowHeaderBar, FHWorkflowTasksPanel, FHWorkflowView, FH_ERROR_REPORTER, FH_EVENT_ID_HEADER, FH_ROUTE_HEADER, FSInput, FSResult, FileService, GridService, LocalDBService, MonthYearPickerComponent, NumericEditorComponent, OdbcService, OfficeAutomatorService, OfficeOperation, OfficeResult, QGParam, QGResult, QParam, QResult, QueryOpenService, QueryService, RegistrationService, ReplaceLineBreaks, SafePipe, TextAreaEditorComponent, UtilityService, WkfService, YearPickerComponent, createButtonCommand, createCheckboxCommand, createSpacerCommand, createTableManagerCommand, fh_win_translate, wkfField };
43200
43305
  //# sourceMappingURL=fluxhub-fluxhub-lib.mjs.map