@smartbit4all/ng-client 4.5.10 → 4.5.12

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.
@@ -6,3 +6,4 @@ export * from './smart-timer/smart-session-timer.component';
6
6
  export * from './smart-timer/smart-session-timer.service';
7
7
  export * from './smart-backend-bootstrap.service';
8
8
  export * from './smart-backend-bootstrap.config';
9
+ export * from './smart-default-error-ui.service';
@@ -1,3 +1,4 @@
1
+ import { HttpErrorResponse } from '@angular/common/http';
1
2
  import { UiActionDescriptor } from '../view-context/api';
2
3
  import { SmartViewHandlerModel } from '../view-context/smart-view-context.model';
3
4
  import { SessionError } from './smart-session-handler.service';
@@ -23,7 +24,11 @@ export interface SmartBackendBootstrapCredentials {
23
24
  export interface SmartBackendBootstrapConfig {
24
25
  url: string;
25
26
  cookieName: string;
26
- messageDialogName: string;
27
+ /**
28
+ * View name the backend uses for generic message dialogs. Defaults to
29
+ * `'message-dialog'` (the platform convention) when omitted.
30
+ */
31
+ messageDialogName?: string;
27
32
  viewHandlers: SmartViewHandlerModel[];
28
33
  actionDescriptors: Map<string, UiActionDescriptor>;
29
34
  /** Optional override for the default `handleSessionError` flow. */
@@ -32,6 +37,17 @@ export interface SmartBackendBootstrapConfig {
32
37
  onSmartLink?: (channel: string) => Promise<void> | void;
33
38
  /** Hook for host UX when `start()` rejects (snackbar + retry). */
34
39
  onStartError?: (err: unknown) => Promise<void> | void;
40
+ /**
41
+ * Hook called when a BFF call fails at the transport level — server
42
+ * unreachable (status 0), gateway/service-unavailable (502/503/504), or
43
+ * generic server-error (500). Default: a console.warn line; the request
44
+ * still rejects with the original error, allowing per-call handling.
45
+ *
46
+ * Fire-and-forget: every failed request invokes the hook (no dedup); the
47
+ * host is responsible for own UI deduplication if needed (e.g. snackbar
48
+ * with a "this message is already showing" guard).
49
+ */
50
+ onTransportError?: (err: HttpErrorResponse) => Promise<void> | void;
35
51
  /**
36
52
  * Hook called when the backend reports the current viewContext is gone
37
53
  * (logout, session expiry, backend restart) — i.e. when the
@@ -1,3 +1,4 @@
1
+ import { HttpErrorResponse } from '@angular/common/http';
1
2
  import { SmartSessionService } from './smart-session.service';
2
3
  import { SmartViewContextService } from '../view-context/smart-view-context.service';
3
4
  import { SessionError, SmartSessionHandlerService } from './smart-session-handler.service';
@@ -26,6 +27,12 @@ export declare class SmartBackendBootstrapService implements SmartSessionHandler
26
27
  */
27
28
  handleViewContextLost(err: SessionError): Promise<void>;
28
29
  private runViewContextLost;
30
+ /**
31
+ * Called by `SmartErrorCatchingInterceptor` for transport-level failures
32
+ * (status 0, 5xx). Fire-and-forget; the request still rejects with the
33
+ * original error so callers can do per-call handling.
34
+ */
35
+ handleTransportError(err: HttpErrorResponse): Promise<void>;
29
36
  private runInit;
30
37
  private runBootstrapWith;
31
38
  private handleInitFailure;
@@ -0,0 +1,90 @@
1
+ import { HttpErrorResponse } from '@angular/common/http';
2
+ import { SessionError } from './smart-session-handler.service';
3
+ import * as i0 from "@angular/core";
4
+ export type DefaultErrorUiLanguage = 'hu' | 'en' | 'auto';
5
+ export interface DefaultErrorUiStrings {
6
+ startErrorMessage: string;
7
+ startErrorRetry: string;
8
+ transportErrorMessage: string;
9
+ transportErrorReload: string;
10
+ sessionErrorMessage: string;
11
+ sessionErrorAction: string;
12
+ }
13
+ export interface DefaultErrorUiOptions {
14
+ /** 'auto' (default) picks 'hu' if navigator.language starts with 'hu', else 'en'. */
15
+ language?: DefaultErrorUiLanguage;
16
+ /** Override individual strings; missing keys fall back to the language default. */
17
+ strings?: Partial<DefaultErrorUiStrings>;
18
+ /**
19
+ * Snackbar auto-dismiss in ms for transportError. Default: 0 (sticky).
20
+ *
21
+ * Sticky default rationale: a transport error commonly leaves the screen in
22
+ * an inconsistent state (failed component loads, stuck spinners) that does
23
+ * NOT self-recover when the server returns. An auto-dismissing snackbar
24
+ * would hide the notification before the user can act, leaving them with a
25
+ * broken UI and no way back. Sticky forces the Reload action.
26
+ *
27
+ * Set a positive number to opt into auto-dismiss (e.g. mobile-shell flows
28
+ * where the shell tears down the webview on transport error anyway).
29
+ *
30
+ * `startError` is always sticky regardless — the app is unusable until the
31
+ * user retries.
32
+ */
33
+ transportErrorDuration?: number;
34
+ }
35
+ /**
36
+ * Opt-in default UX for `SmartBackendBootstrapService` error hooks.
37
+ *
38
+ * Spread the result of `hooks(options)` into `bootstrap.configure()` to get a
39
+ * MatSnackBar-based "error + retry" UI without writing the host glue:
40
+ *
41
+ * ```ts
42
+ * bootstrap.configure({
43
+ * ...minimalConfig,
44
+ * ...defaultErrorUi.hooks({ language: 'hu' }),
45
+ * });
46
+ * ```
47
+ *
48
+ * Hosts that want custom logic can omit this service and write their own
49
+ * `onStartError` / `onTransportError` callbacks directly.
50
+ */
51
+ export declare class SmartDefaultErrorUiService {
52
+ private snackBar;
53
+ private session;
54
+ /** Returns a hooks bundle ready to spread into `bootstrap.configure()`. */
55
+ hooks(options?: DefaultErrorUiOptions): {
56
+ onStartError: (err: unknown) => void;
57
+ onTransportError: (err: HttpErrorResponse) => void;
58
+ onSessionError: (err: SessionError) => void;
59
+ };
60
+ showStartError(_err: unknown, options?: DefaultErrorUiOptions): void;
61
+ showTransportError(_err: HttpErrorResponse, options?: DefaultErrorUiOptions): void;
62
+ showSessionError(_err: SessionError, options?: DefaultErrorUiOptions): void;
63
+ /**
64
+ * Clears the dead session and reloads. Unlike `verifyServerAndReload`, this
65
+ * does NOT pre-check via `getSession()` — the SID is known to be invalid,
66
+ * so the check would fail. We best-effort `clearAndStartNewSession()`
67
+ * (creates a fresh anonymous session); reload happens regardless so the
68
+ * user is not stuck if the clear fails (e.g., server flapping).
69
+ *
70
+ * Overridable in tests.
71
+ */
72
+ protected recoverSession(): Promise<void>;
73
+ /**
74
+ * Pings `getSession()` before reloading: if the server is still down, the
75
+ * reload would just re-trigger the broken-screen state. The failed check
76
+ * goes through `SmartErrorCatchingInterceptor` and re-fires `onTransportError`,
77
+ * so the user sees a fresh snackbar — they get visible feedback that the
78
+ * server is still unreachable, without paying the cost of a full bundle
79
+ * reload that lands on the same broken state.
80
+ *
81
+ * Overridable in tests.
82
+ */
83
+ protected verifyServerAndReload(): Promise<void>;
84
+ /** Overridable in tests. */
85
+ protected reloadPage(): void;
86
+ private resolveStrings;
87
+ private resolveLanguage;
88
+ static ɵfac: i0.ɵɵFactoryDeclaration<SmartDefaultErrorUiService, never>;
89
+ static ɵprov: i0.ɵɵInjectableDeclaration<SmartDefaultErrorUiService>;
90
+ }
@@ -11,6 +11,7 @@ export declare class SmartErrorCatchingInterceptor implements HttpInterceptor {
11
11
  intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>>;
12
12
  private handleError;
13
13
  private isSessionError;
14
+ private isTransportError;
14
15
  private getSessionError;
15
16
  private resolveError;
16
17
  private updateRequestHeaders;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartbit4all/ng-client",
3
- "version": "4.5.10",
3
+ "version": "4.5.12",
4
4
  "peerDependencies": {
5
5
  "@angular/animations": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
6
6
  "@angular/common": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
Binary file