@hmcts/opal-frontend-common 0.0.45 → 0.0.46

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.
@@ -0,0 +1,18 @@
1
+ const ERROR_RESPONSE = {
2
+ type: null,
3
+ title: null,
4
+ status: null,
5
+ detail: null,
6
+ instance: null,
7
+ operation_id: null,
8
+ retriable: null,
9
+ };
10
+
11
+ const GENERIC_HTTP_ERROR_MESSAGE = 'You can try again. If the problem persists, contact the service desk.';
12
+
13
+ /**
14
+ * Generated bundle index. Do not edit.
15
+ */
16
+
17
+ export { ERROR_RESPONSE, GENERIC_HTTP_ERROR_MESSAGE };
18
+ //# sourceMappingURL=hmcts-opal-frontend-common-interceptors-http-error-constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmcts-opal-frontend-common-interceptors-http-error-constants.mjs","sources":["../../../projects/opal-frontend-common/interceptors/http-error/constants/http-error-message-response.constant.ts","../../../projects/opal-frontend-common/interceptors/http-error/constants/http-error-message.constant.ts","../../../projects/opal-frontend-common/interceptors/http-error/constants/hmcts-opal-frontend-common-interceptors-http-error-constants.ts"],"sourcesContent":["import { IErrorResponse } from '@hmcts/opal-frontend-common/interceptors/http-error/interfaces';\n\nexport const ERROR_RESPONSE: IErrorResponse = {\n type: null,\n title: null,\n status: null,\n detail: null,\n instance: null,\n operation_id: null,\n retriable: null,\n};\n","export const GENERIC_HTTP_ERROR_MESSAGE = 'You can try again. If the problem persists, contact the service desk.';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAEO,MAAM,cAAc,GAAmB;AAC5C,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,MAAM,EAAE,IAAI;AACZ,IAAA,MAAM,EAAE,IAAI;AACZ,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,YAAY,EAAE,IAAI;AAClB,IAAA,SAAS,EAAE,IAAI;;;ACTV,MAAM,0BAA0B,GAAG;;ACA1C;;AAEG;;;;"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ //# sourceMappingURL=hmcts-opal-frontend-common-interceptors-http-error-interfaces.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmcts-opal-frontend-common-interceptors-http-error-interfaces.mjs","sources":["../../../projects/opal-frontend-common/interceptors/http-error/interfaces/hmcts-opal-frontend-common-interceptors-http-error-interfaces.ts"],"sourcesContent":["/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;AAEG"}
@@ -1,24 +1,123 @@
1
1
  import { inject } from '@angular/core';
2
+ import { Router } from '@angular/router';
2
3
  import { tap, catchError, throwError } from 'rxjs';
3
4
  import { AppInsightsService } from '@hmcts/opal-frontend-common/services/app-insights-service';
4
5
  import { GlobalStore } from '@hmcts/opal-frontend-common/stores/global';
6
+ import { GLOBAL_ERROR_STATE } from '@hmcts/opal-frontend-common/stores/global/constants';
5
7
 
6
- const GENERIC_HTTP_ERROR_MESSAGE = 'An error has occurred. Please try again, if this problem persists, contact the help desk.';
8
+ const GENERIC_HTTP_ERROR_MESSAGE = 'You can try again. If the problem persists, contact the service desk.';
7
9
 
10
+ const ERROR_RESPONSE = {
11
+ type: null,
12
+ title: null,
13
+ status: null,
14
+ detail: null,
15
+ instance: null,
16
+ operation_id: null,
17
+ retriable: null,
18
+ };
19
+
20
+ /**
21
+ * Checks if the error is a non-retriable error
22
+ * @param error - The HTTP error response
23
+ * @returns true if the error has retriable: false
24
+ */
25
+ function isNonRetriableError(error) {
26
+ if (typeof error === 'object' && error !== null && 'error' in error) {
27
+ const err = error;
28
+ return err.error?.retriable === false;
29
+ }
30
+ return false;
31
+ }
32
+ /**
33
+ * Checks if the error is explicitly marked as retriable
34
+ * @param error - The HTTP error response
35
+ * @returns true if the error has retriable: true or retriable is undefined
36
+ */
37
+ function isRetriableError(error) {
38
+ if (typeof error === 'object' && error !== null && 'error' in error) {
39
+ const err = error;
40
+ return err.error?.retriable !== false;
41
+ }
42
+ return false;
43
+ }
44
+ /**
45
+ * Handles retriable errors by setting appropriate error state
46
+ * @param error - The HTTP error response
47
+ * @param globalStore - Global store instance
48
+ */
49
+ function handleRetriableError(error, globalStore) {
50
+ let errorResponse;
51
+ if (typeof error === 'object' && error !== null && 'error' in error) {
52
+ const err = error;
53
+ errorResponse = err.error;
54
+ }
55
+ const errorMessage = errorResponse?.detail || GENERIC_HTTP_ERROR_MESSAGE;
56
+ globalStore.setError({
57
+ ...GLOBAL_ERROR_STATE,
58
+ error: true,
59
+ title: errorResponse?.title || ERROR_RESPONSE.title,
60
+ message: errorMessage,
61
+ operationId: errorResponse?.operation_id || ERROR_RESPONSE.operation_id,
62
+ });
63
+ }
64
+ /**
65
+ * Handles non-retriable errors by redirecting to appropriate error pages
66
+ * @param error - The HTTP error response
67
+ * @param router - Angular Router instance
68
+ */
69
+ function handleNonRetriableError(error, router) {
70
+ let errorResponse;
71
+ let status;
72
+ if (typeof error === 'object' && error !== null) {
73
+ if ('error' in error) {
74
+ const err = error;
75
+ errorResponse = err.error;
76
+ }
77
+ if ('status' in error) {
78
+ const statusErr = error;
79
+ status = statusErr.status;
80
+ }
81
+ }
82
+ const statusCode = status || errorResponse?.status;
83
+ switch (statusCode) {
84
+ case 409:
85
+ router.navigate(['/error/concurrency-failure']);
86
+ break;
87
+ case 403:
88
+ router.navigate(['/error/permission-denied']);
89
+ break;
90
+ default:
91
+ router.navigate(['/error/internal-server-error']);
92
+ break;
93
+ }
94
+ }
8
95
  const httpErrorInterceptor = (req, next) => {
9
96
  const globalStore = inject(GlobalStore);
10
97
  const appInsightsService = inject(AppInsightsService);
98
+ const router = inject(Router);
11
99
  return next(req).pipe(tap(() => {
12
- // Clear the state service on new requests
13
- globalStore.setError({ error: false, message: '' });
100
+ globalStore.setError({ ...GLOBAL_ERROR_STATE, error: false });
14
101
  }), catchError((error) => {
15
102
  const isBrowser = typeof globalThis !== 'undefined';
16
103
  if (isBrowser) {
17
- globalStore.setError({
18
- error: true,
19
- message: GENERIC_HTTP_ERROR_MESSAGE,
20
- });
104
+ if (isNonRetriableError(error)) {
105
+ handleNonRetriableError(error, router);
106
+ }
107
+ else if (isRetriableError(error)) {
108
+ handleRetriableError(error, globalStore);
109
+ }
110
+ else {
111
+ globalStore.setError({
112
+ ...GLOBAL_ERROR_STATE,
113
+ error: true,
114
+ title: 'There was a problem',
115
+ message: GENERIC_HTTP_ERROR_MESSAGE,
116
+ operationId: ERROR_RESPONSE.operation_id,
117
+ });
118
+ }
21
119
  }
120
+ // Always log exceptions for monitoring
22
121
  appInsightsService.logException(error);
23
122
  return throwError(() => error);
24
123
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"hmcts-opal-frontend-common-interceptors-http-error.mjs","sources":["../../../projects/opal-frontend-common/interceptors/http-error/constants/http-error-message.constant.ts","../../../projects/opal-frontend-common/interceptors/http-error/http-error.interceptor.ts","../../../projects/opal-frontend-common/interceptors/http-error/hmcts-opal-frontend-common-interceptors-http-error.ts"],"sourcesContent":["export const GENERIC_HTTP_ERROR_MESSAGE =\n 'An error has occurred. Please try again, if this problem persists, contact the help desk.';\n","import { HttpInterceptorFn } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport { catchError, tap, throwError } from 'rxjs';\nimport { AppInsightsService } from '@hmcts/opal-frontend-common/services/app-insights-service';\nimport { GlobalStore } from '@hmcts/opal-frontend-common/stores/global';\nimport { GENERIC_HTTP_ERROR_MESSAGE } from './constants/http-error-message.constant';\n\nexport const httpErrorInterceptor: HttpInterceptorFn = (req, next) => {\n const globalStore = inject(GlobalStore);\n const appInsightsService = inject(AppInsightsService);\n\n return next(req).pipe(\n tap(() => {\n // Clear the state service on new requests\n globalStore.setError({ error: false, message: '' });\n }),\n catchError((error) => {\n const isBrowser = typeof globalThis !== 'undefined';\n\n if (isBrowser) {\n globalStore.setError({\n error: true,\n message: GENERIC_HTTP_ERROR_MESSAGE,\n });\n }\n\n appInsightsService.logException(error);\n\n return throwError(() => error);\n }),\n );\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAO,MAAM,0BAA0B,GACrC,2FAA2F;;MCMhF,oBAAoB,GAAsB,CAAC,GAAG,EAAE,IAAI,KAAI;AACnE,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;AACvC,IAAA,MAAM,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC;IAErD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CACnB,GAAG,CAAC,MAAK;;AAEP,QAAA,WAAW,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;AACrD,IAAA,CAAC,CAAC,EACF,UAAU,CAAC,CAAC,KAAK,KAAI;AACnB,QAAA,MAAM,SAAS,GAAG,OAAO,UAAU,KAAK,WAAW;QAEnD,IAAI,SAAS,EAAE;YACb,WAAW,CAAC,QAAQ,CAAC;AACnB,gBAAA,KAAK,EAAE,IAAI;AACX,gBAAA,OAAO,EAAE,0BAA0B;AACpC,aAAA,CAAC;QACJ;AAEA,QAAA,kBAAkB,CAAC,YAAY,CAAC,KAAK,CAAC;AAEtC,QAAA,OAAO,UAAU,CAAC,MAAM,KAAK,CAAC;IAChC,CAAC,CAAC,CACH;AACH;;AC/BA;;AAEG;;;;"}
1
+ {"version":3,"file":"hmcts-opal-frontend-common-interceptors-http-error.mjs","sources":["../../../projects/opal-frontend-common/interceptors/http-error/constants/http-error-message.constant.ts","../../../projects/opal-frontend-common/interceptors/http-error/constants/http-error-message-response.constant.ts","../../../projects/opal-frontend-common/interceptors/http-error/http-error.interceptor.ts","../../../projects/opal-frontend-common/interceptors/http-error/hmcts-opal-frontend-common-interceptors-http-error.ts"],"sourcesContent":["export const GENERIC_HTTP_ERROR_MESSAGE = 'You can try again. If the problem persists, contact the service desk.';\n","import { IErrorResponse } from '@hmcts/opal-frontend-common/interceptors/http-error/interfaces';\n\nexport const ERROR_RESPONSE: IErrorResponse = {\n type: null,\n title: null,\n status: null,\n detail: null,\n instance: null,\n operation_id: null,\n retriable: null,\n};\n","import { HttpInterceptorFn } from '@angular/common/http';\nimport { inject } from '@angular/core';\nimport { Router } from '@angular/router';\nimport { catchError, tap, throwError } from 'rxjs';\nimport { AppInsightsService } from '@hmcts/opal-frontend-common/services/app-insights-service';\nimport { GlobalStore } from '@hmcts/opal-frontend-common/stores/global';\nimport { GLOBAL_ERROR_STATE } from '@hmcts/opal-frontend-common/stores/global/constants';\nimport { GlobalStoreType } from '@hmcts/opal-frontend-common/stores/global/types';\nimport { GENERIC_HTTP_ERROR_MESSAGE } from './constants/http-error-message.constant';\nimport { IErrorResponse } from './interfaces/http-error-retrievable-error-response.interface';\nimport { ERROR_RESPONSE } from './constants/http-error-message-response.constant';\n/**\n * Checks if the error is a non-retriable error\n * @param error - The HTTP error response\n * @returns true if the error has retriable: false\n */\nfunction isNonRetriableError(error: unknown): boolean {\n if (typeof error === 'object' && error !== null && 'error' in error) {\n const err = error as { error?: { retriable?: boolean } };\n return err.error?.retriable === false;\n }\n return false;\n}\n\n/**\n * Checks if the error is explicitly marked as retriable\n * @param error - The HTTP error response\n * @returns true if the error has retriable: true or retriable is undefined\n */\nfunction isRetriableError(error: unknown): boolean {\n if (typeof error === 'object' && error !== null && 'error' in error) {\n const err = error as { error?: { retriable?: boolean } };\n return err.error?.retriable !== false;\n }\n return false;\n}\n\n/**\n * Handles retriable errors by setting appropriate error state\n * @param error - The HTTP error response\n * @param globalStore - Global store instance\n */\nfunction handleRetriableError(error: unknown, globalStore: GlobalStoreType): void {\n let errorResponse: IErrorResponse | undefined;\n\n if (typeof error === 'object' && error !== null && 'error' in error) {\n const err = error as { error?: IErrorResponse };\n errorResponse = err.error;\n }\n\n const errorMessage = errorResponse?.detail || GENERIC_HTTP_ERROR_MESSAGE;\n\n globalStore.setError({\n ...GLOBAL_ERROR_STATE,\n error: true,\n title: errorResponse?.title || ERROR_RESPONSE.title,\n message: errorMessage,\n operationId: errorResponse?.operation_id || ERROR_RESPONSE.operation_id,\n });\n}\n\n/**\n * Handles non-retriable errors by redirecting to appropriate error pages\n * @param error - The HTTP error response\n * @param router - Angular Router instance\n */\nfunction handleNonRetriableError(error: unknown, router: Router): void {\n let errorResponse: IErrorResponse | undefined;\n let status: number | undefined;\n\n if (typeof error === 'object' && error !== null) {\n if ('error' in error) {\n const err = error as { error?: IErrorResponse };\n errorResponse = err.error;\n }\n if ('status' in error) {\n const statusErr = error as { status?: number };\n status = statusErr.status;\n }\n }\n\n const statusCode = status || errorResponse?.status;\n\n switch (statusCode) {\n case 409:\n router.navigate(['/error/concurrency-failure']);\n break;\n case 403:\n router.navigate(['/error/permission-denied']);\n break;\n default:\n router.navigate(['/error/internal-server-error']);\n break;\n }\n}\n\nexport const httpErrorInterceptor: HttpInterceptorFn = (req, next) => {\n const globalStore = inject(GlobalStore);\n const appInsightsService = inject(AppInsightsService);\n const router = inject(Router);\n\n return next(req).pipe(\n tap(() => {\n globalStore.setError({ ...GLOBAL_ERROR_STATE, error: false });\n }),\n catchError((error) => {\n const isBrowser = typeof globalThis !== 'undefined';\n\n if (isBrowser) {\n if (isNonRetriableError(error)) {\n handleNonRetriableError(error, router);\n } else if (isRetriableError(error)) {\n handleRetriableError(error, globalStore);\n } else {\n globalStore.setError({\n ...GLOBAL_ERROR_STATE,\n error: true,\n title: 'There was a problem',\n message: GENERIC_HTTP_ERROR_MESSAGE,\n operationId: ERROR_RESPONSE.operation_id,\n });\n }\n }\n\n // Always log exceptions for monitoring\n appInsightsService.logException(error);\n\n return throwError(() => error);\n }),\n );\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAAO,MAAM,0BAA0B,GAAG,uEAAuE;;ACE1G,MAAM,cAAc,GAAmB;AAC5C,IAAA,IAAI,EA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AQ,CAAC,EAAE,GAAG,kBAAkB,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC/D,IAAA,CAAC,CAAC,EACF,UAAU,CAAC,CAAC,KAAK,KAAI;AACnB,QAAA,MAAM,SAAS,GAAG,OAAO,UAAU,KAAK,WAAW;QAEnD,IAAI,SAAS,EAAE;AACb,YAAA,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE;AAC9B,gBAAA,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC;YACxC;AAAO,iBAAA,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;AAClC,gBAAA,oBAAoB,CAAC,KAAK,EAAE,WAAW,CAAC;YAC1C;iBAAO;gBACL,WAAW,CAAC,QAAQ,CAAC;AACnB,oBAAA,GAAG,kBAAkB;AACrB,oBAAA,KAAK,EAAE,IAAI;AACX,oBAAA,KAAK,EAAE,qBAAqB;AAC5B,oBAAA,OAAO,EAAE,0BAA0B;oBACnC,WAAW,EAAE,cAAc,CAAC,YAAY;AACzC,iBAAA,CAAC;YACJ;QACF;;AAGA,QAAA,kBAAkB,CAAC,YAAY,CAAC,KAAK,CAAC;AAEtC,QAAA,OAAO,UAAU,CAAC,MAAM,KAAK,CAAC;IAChC,CAAC,CAAC,CACH;AACH;;AClIA;;AAEG;;;;"}
@@ -0,0 +1,13 @@
1
+ const GLOBAL_ERROR_STATE = {
2
+ error: null,
3
+ title: null,
4
+ message: null,
5
+ operationId: null,
6
+ };
7
+
8
+ /**
9
+ * Generated bundle index. Do not edit.
10
+ */
11
+
12
+ export { GLOBAL_ERROR_STATE };
13
+ //# sourceMappingURL=hmcts-opal-frontend-common-stores-global-constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmcts-opal-frontend-common-stores-global-constants.mjs","sources":["../../../projects/opal-frontend-common/stores/global/constants/global-store-error-state.constant.ts","../../../projects/opal-frontend-common/stores/global/constants/hmcts-opal-frontend-common-stores-global-constants.ts"],"sourcesContent":["import { IGlobalErrorState } from '@hmcts/opal-frontend-common/stores/global/interfaces';\n\nexport const GLOBAL_ERROR_STATE: IGlobalErrorState = {\n error: null,\n title: null,\n message: null,\n operationId: null,\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAEO,MAAM,kBAAkB,GAAsB;AACnD,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,KAAK,EAAE,IAAI;AACX,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,WAAW,EAAE,IAAI;;;ACNnB;;AAEG;;;;"}
@@ -1,8 +1,9 @@
1
1
  import { signalStore, withState, withMethods, patchState } from '@ngrx/signals';
2
+ import { GLOBAL_ERROR_STATE } from '@hmcts/opal-frontend-common/stores/global/constants';
2
3
 
3
4
  const GlobalStore = signalStore({ providedIn: 'root' }, withState(() => ({
4
5
  authenticated: false,
5
- error: { error: false, message: '' },
6
+ error: { ...GLOBAL_ERROR_STATE },
6
7
  featureFlags: {},
7
8
  userState: {},
8
9
  ssoEnabled: false,
@@ -34,6 +35,9 @@ const GlobalStore = signalStore({ providedIn: 'root' }, withState(() => ({
34
35
  setTokenExpiry: (tokenExpiry) => {
35
36
  patchState(store, { tokenExpiry });
36
37
  },
38
+ resetError: () => {
39
+ patchState(store, { error: { ...GLOBAL_ERROR_STATE } });
40
+ },
37
41
  })));
38
42
 
39
43
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"hmcts-opal-frontend-common-stores-global.mjs","sources":["../../../projects/opal-frontend-common/stores/global/global.store.ts","../../../projects/opal-frontend-common/stores/global/hmcts-opal-frontend-common-stores-global.ts"],"sourcesContent":["import { patchState, signalStore, withMethods, withState } from '@ngrx/signals';\nimport { LDFlagSet } from 'launchdarkly-js-client-sdk';\nimport {\n ITransferStateLaunchDarklyConfig,\n ITransferStateAppInsightsConfig,\n} from '@hmcts/opal-frontend-common/services/transfer-state-service/interfaces';\nimport { ISessionTokenExpiry } from '@hmcts/opal-frontend-common/services/session-service/interfaces';\nimport { IErrorState } from '@hmcts/opal-frontend-common/stores/global/interfaces';\nimport { IOpalUserState } from '@hmcts/opal-frontend-common/services/opal-user-service/interfaces';\n\nexport const GlobalStore = signalStore(\n { providedIn: 'root' },\n withState(() => ({\n authenticated: false,\n error: { error: false, message: '' },\n featureFlags: {} as LDFlagSet,\n userState: {} as IOpalUserState,\n ssoEnabled: false,\n launchDarklyConfig: {} as ITransferStateLaunchDarklyConfig,\n appInsightsConfig: {} as ITransferStateAppInsightsConfig,\n tokenExpiry: {} as ISessionTokenExpiry,\n })),\n withMethods((store) => ({\n setAuthenticated: (authenticated: boolean) => {\n patchState(store, { authenticated });\n },\n setError: (error: IErrorState) => {\n patchState(store, { error });\n },\n setFeatureFlags: (featureFlags: LDFlagSet) => {\n patchState(store, { featureFlags });\n },\n setUserState: (userState: IOpalUserState) => {\n patchState(store, { userState });\n },\n setSsoEnabled: (ssoEnabled: boolean) => {\n patchState(store, { ssoEnabled });\n },\n setLaunchDarklyConfig: (config: ITransferStateLaunchDarklyConfig) => {\n patchState(store, { launchDarklyConfig: config });\n },\n setAppInsightsConfig: (config: ITransferStateAppInsightsConfig) => {\n patchState(store, { appInsightsConfig: config });\n },\n setTokenExpiry: (tokenExpiry: ISessionTokenExpiry) => {\n patchState(store, { tokenExpiry });\n },\n })),\n);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAUO,MAAM,WAAW,GAAG,WAAW,CACpC,EAAE,UAAU,EAAE,MAAM,EAAE,EACtB,SAAS,CAAC,OAAO;AACf,IAAA,aAAa,EAAE,KAAK;IACpB,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE;AACpC,IAAA,YAAY,EAAE,EAAe;AAC7B,IAAA,SAAS,EAAE,EAAoB;AAC/B,IAAA,UAAU,EAAE,KAAK;AACjB,IAAA,kBAAkB,EAAE,EAAsC;AAC1D,IAAA,iBAAiB,EAAE,EAAqC;AACxD,IAAA,WAAW,EAAE,EAAyB;CACvC,CAAC,CAAC,EACH,WAAW,CAAC,CAAC,KAAK,MAAM;AACtB,IAAA,gBAAgB,EAAE,CAAC,aAAsB,KAAI;AAC3C,QAAA,UAAU,CAAC,KAAK,EAAE,EAAE,aAAa,EAAE,CAAC;IACtC,CAAC;AACD,IAAA,QAAQ,EAAE,CAAC,KAAkB,KAAI;AAC/B,QAAA,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC;AACD,IAAA,eAAe,EAAE,CAAC,YAAuB,KAAI;AAC3C,QAAA,UAAU,CAAC,KAAK,EAAE,EAAE,YAAY,EAAE,CAAC;IACrC,CAAC;AACD,IAAA,YAAY,EAAE,CAAC,SAAyB,KAAI;AAC1C,QAAA,UAAU,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC;IAClC,CAAC;AACD,IAAA,aAAa,EAAE,CAAC,UAAmB,KAAI;AACrC,QAAA,UAAU,CAAC,KAAK,EAAE,EAAE,UAAU,EAAE,CAAC;IACnC,CAAC;AACD,IAAA,qBAAqB,EAAE,CAAC,MAAwC,KAAI;QAClE,UAAU,CAAC,KAAK,EAAE,EAAE,kBAAkB,EAAE,MAAM,EAAE,CAAC;IACnD,CAAC;AACD,IAAA,oBAAoB,EAAE,CAAC,MAAuC,KAAI;QAChE,UAAU,CAAC,KAAK,EAAE,EAAE,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAClD,CAAC;AACD,IAAA,cAAc,EAAE,CAAC,WAAgC,KAAI;AACnD,QAAA,UAAU,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC;IACpC,CAAC;CACF,CAAC,CAAC;;AC/CL;;AAEG;;;;"}
1
+ {"version":3,"file":"hmcts-opal-frontend-common-stores-global.mjs","sources":["../../../projects/opal-frontend-common/stores/global/global.store.ts","../../../projects/opal-frontend-common/stores/global/hmcts-opal-frontend-common-stores-global.ts"],"sourcesContent":["import { patchState, signalStore, withMethods, withState } from '@ngrx/signals';\nimport { LDFlagSet } from 'launchdarkly-js-client-sdk';\nimport {\n ITransferStateLaunchDarklyConfig,\n ITransferStateAppInsightsConfig,\n} from '@hmcts/opal-frontend-common/services/transfer-state-service/interfaces';\nimport { ISessionTokenExpiry } from '@hmcts/opal-frontend-common/services/session-service/interfaces';\nimport { IGlobalErrorState } from '@hmcts/opal-frontend-common/stores/global/interfaces';\nimport { IOpalUserState } from '@hmcts/opal-frontend-common/services/opal-user-service/interfaces';\nimport { GLOBAL_ERROR_STATE } from '@hmcts/opal-frontend-common/stores/global/constants';\nexport const GlobalStore = signalStore(\n { providedIn: 'root' },\n withState(() => ({\n authenticated: false,\n error: { ...GLOBAL_ERROR_STATE },\n featureFlags: {} as LDFlagSet,\n userState: {} as IOpalUserState,\n ssoEnabled: false,\n launchDarklyConfig: {} as ITransferStateLaunchDarklyConfig,\n appInsightsConfig: {} as ITransferStateAppInsightsConfig,\n tokenExpiry: {} as ISessionTokenExpiry,\n })),\n withMethods((store) => ({\n setAuthenticated: (authenticated: boolean) => {\n patchState(store, { authenticated });\n },\n setError: (error: IGlobalErrorState) => {\n patchState(store, { error });\n },\n setFeatureFlags: (featureFlags: LDFlagSet) => {\n patchState(store, { featureFlags });\n },\n setUserState: (userState: IOpalUserState) => {\n patchState(store, { userState });\n },\n setSsoEnabled: (ssoEnabled: boolean) => {\n patchState(store, { ssoEnabled });\n },\n setLaunchDarklyConfig: (config: ITransferStateLaunchDarklyConfig) => {\n patchState(store, { launchDarklyConfig: config });\n },\n setAppInsightsConfig: (config: ITransferStateAppInsightsConfig) => {\n patchState(store, { appInsightsConfig: config });\n },\n setTokenExpiry: (tokenExpiry: ISessionTokenExpiry) => {\n patchState(store, { tokenExpiry });\n },\n resetError: () => {\n patchState(store, { error: { ...GLOBAL_ERROR_STATE } });\n },\n })),\n);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAUO,MAAM,WAAW,GAAG,WAAW,CACpC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AE,CAAC,WAAgC,KAAI;AACnD,QAAA,UAAU,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC;IACpC,CAAC;IACD,UAAU,EAAE,MAAK;AACf,QAAA,UAAU,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,GAAG,kBAAkB,EAAE,EAAE,CAAC;IACzD,CAAC;CACF,CAAC,CAAC;;AClDL;;AAEG;;;;"}
@@ -0,0 +1,7 @@
1
+ import { IErrorResponse } from '@hmcts/opal-frontend-common/interceptors/http-error/interfaces';
2
+
3
+ declare const ERROR_RESPONSE: IErrorResponse;
4
+
5
+ declare const GENERIC_HTTP_ERROR_MESSAGE = "You can try again. If the problem persists, contact the service desk.";
6
+
7
+ export { ERROR_RESPONSE, GENERIC_HTTP_ERROR_MESSAGE };
@@ -0,0 +1,11 @@
1
+ interface IErrorResponse {
2
+ type: string | null;
3
+ title: string | null;
4
+ status: number | null;
5
+ detail: string | null;
6
+ instance: string | null;
7
+ operation_id: string | null;
8
+ retriable: boolean | null;
9
+ }
10
+
11
+ export type { IErrorResponse };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmcts/opal-frontend-common",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "license": "MIT",
5
5
  "peerDependencies": {
6
6
  "@angular/common": "^18.2.0 || ^19.0.0 || ^20.0.0",
@@ -577,6 +577,16 @@
577
577
  "types": "./interceptors/http-error/index.d.ts",
578
578
  "default": "./fesm2022/hmcts-opal-frontend-common-interceptors-http-error.mjs"
579
579
  },
580
+ "./interceptors/http-error/constants": {
581
+ "import": "./fesm2022/hmcts-opal-frontend-common-interceptors-http-error-constants.mjs",
582
+ "types": "./interceptors/http-error/constants/index.d.ts",
583
+ "default": "./fesm2022/hmcts-opal-frontend-common-interceptors-http-error-constants.mjs"
584
+ },
585
+ "./interceptors/http-error/interfaces": {
586
+ "import": "./fesm2022/hmcts-opal-frontend-common-interceptors-http-error-interfaces.mjs",
587
+ "types": "./interceptors/http-error/interfaces/index.d.ts",
588
+ "default": "./fesm2022/hmcts-opal-frontend-common-interceptors-http-error-interfaces.mjs"
589
+ },
580
590
  "./pages/routing": {
581
591
  "import": "./fesm2022/hmcts-opal-frontend-common-pages.mjs"
582
592
  },
@@ -756,6 +766,11 @@
756
766
  "types": "./stores/global/types/index.d.ts",
757
767
  "default": "./fesm2022/hmcts-opal-frontend-common-stores-global-types.mjs"
758
768
  },
769
+ "./stores/global/constants": {
770
+ "import": "./fesm2022/hmcts-opal-frontend-common-stores-global-constants.mjs",
771
+ "types": "./stores/global/constants/index.d.ts",
772
+ "default": "./fesm2022/hmcts-opal-frontend-common-stores-global-constants.mjs"
773
+ },
759
774
  "./validators/amount": {
760
775
  "import": "./fesm2022/hmcts-opal-frontend-common-validators-amount.mjs",
761
776
  "types": "./validators/amount/index.d.ts",
@@ -0,0 +1,5 @@
1
+ import { IGlobalErrorState } from '@hmcts/opal-frontend-common/stores/global/interfaces';
2
+
3
+ declare const GLOBAL_ERROR_STATE: IGlobalErrorState;
4
+
5
+ export { GLOBAL_ERROR_STATE };
@@ -3,14 +3,16 @@ import * as _angular_core from '@angular/core';
3
3
  import { LDFlagSet } from 'launchdarkly-js-client-sdk';
4
4
  import { ITransferStateLaunchDarklyConfig, ITransferStateAppInsightsConfig } from '@hmcts/opal-frontend-common/services/transfer-state-service/interfaces';
5
5
  import { ISessionTokenExpiry } from '@hmcts/opal-frontend-common/services/session-service/interfaces';
6
- import { IErrorState } from '@hmcts/opal-frontend-common/stores/global/interfaces';
6
+ import { IGlobalErrorState } from '@hmcts/opal-frontend-common/stores/global/interfaces';
7
7
  import { IOpalUserState } from '@hmcts/opal-frontend-common/services/opal-user-service/interfaces';
8
8
 
9
9
  declare const GlobalStore: _angular_core.Type<{
10
10
  authenticated: _angular_core.Signal<boolean>;
11
11
  error: _ngrx_signals.DeepSignal<{
12
- error: boolean;
13
- message: string;
12
+ error: boolean | null;
13
+ title: string | null;
14
+ message: string | null;
15
+ operationId: string | null;
14
16
  }>;
15
17
  featureFlags: _angular_core.Signal<LDFlagSet>;
16
18
  userState: _ngrx_signals.DeepSignal<IOpalUserState>;
@@ -19,18 +21,21 @@ declare const GlobalStore: _angular_core.Type<{
19
21
  appInsightsConfig: _ngrx_signals.DeepSignal<ITransferStateAppInsightsConfig>;
20
22
  tokenExpiry: _ngrx_signals.DeepSignal<ISessionTokenExpiry>;
21
23
  setAuthenticated: (authenticated: boolean) => void;
22
- setError: (error: IErrorState) => void;
24
+ setError: (error: IGlobalErrorState) => void;
23
25
  setFeatureFlags: (featureFlags: LDFlagSet) => void;
24
26
  setUserState: (userState: IOpalUserState) => void;
25
27
  setSsoEnabled: (ssoEnabled: boolean) => void;
26
28
  setLaunchDarklyConfig: (config: ITransferStateLaunchDarklyConfig) => void;
27
29
  setAppInsightsConfig: (config: ITransferStateAppInsightsConfig) => void;
28
30
  setTokenExpiry: (tokenExpiry: ISessionTokenExpiry) => void;
31
+ resetError: () => void;
29
32
  } & _ngrx_signals.StateSource<{
30
33
  authenticated: boolean;
31
34
  error: {
32
- error: boolean;
33
- message: string;
35
+ error: boolean | null;
36
+ title: string | null;
37
+ message: string | null;
38
+ operationId: string | null;
34
39
  };
35
40
  featureFlags: LDFlagSet;
36
41
  userState: IOpalUserState;
@@ -1,6 +1,8 @@
1
- interface IErrorState {
2
- error: boolean;
3
- message: string;
1
+ interface IGlobalErrorState {
2
+ error: boolean | null;
3
+ title: string | null;
4
+ message: string | null;
5
+ operationId: string | null;
4
6
  }
5
7
 
6
- export type { IErrorState };
8
+ export type { IGlobalErrorState };