@ukpc-lib/react 0.8.17 → 0.9.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.
@@ -0,0 +1,9 @@
1
+ import React, { Component, ErrorInfo, ReactNode } from 'react';
2
+ interface ErrorBoundaryProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps> {
6
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
7
+ render(): React.ReactNode;
8
+ }
9
+ export {};
@@ -0,0 +1 @@
1
+ export declare function initializeAxiosErrorInterceptor(originalRequest: any, error: any): void;
@@ -0,0 +1,6 @@
1
+ type GlobalErrorHandlerProps = {
2
+ app: string;
3
+ lokiUrl: string;
4
+ };
5
+ export declare const initializeGlobalErrorHandling: (props: GlobalErrorHandlerProps) => void;
6
+ export {};
@@ -0,0 +1,13 @@
1
+ import { initializeAxiosErrorInterceptor } from './axiosErrorHandler';
2
+ import { ErrorBoundary } from './ErrorBoundary';
3
+ import { LogToLokiParams } from './logToLoki';
4
+ export type { LogToLokiParams };
5
+ export declare const ErrorManager: {
6
+ ErrorBoundary: typeof ErrorBoundary;
7
+ initializeGlobalErrorHandling: (props: {
8
+ app: string;
9
+ lokiUrl: string;
10
+ }) => void;
11
+ initializeAxiosErrorInterceptor: typeof initializeAxiosErrorInterceptor;
12
+ logToLoki: ({ app, level, message, context, exception, }: LogToLokiParams) => Promise<void>;
13
+ };
@@ -0,0 +1,22 @@
1
+ type LogLevel = 'info' | 'warn' | 'error' | 'debug';
2
+ interface LogContext {
3
+ userId?: string;
4
+ module?: string;
5
+ functionName?: string;
6
+ request?: any;
7
+ response?: any;
8
+ }
9
+ interface ExceptionDetails {
10
+ name: string;
11
+ message: string;
12
+ stackTrace?: string | null;
13
+ }
14
+ export interface LogToLokiParams {
15
+ app?: string;
16
+ level: LogLevel;
17
+ message: string;
18
+ context?: LogContext;
19
+ exception?: ExceptionDetails;
20
+ }
21
+ export declare const logToLoki: ({ app, level, message, context, exception, }: LogToLokiParams) => Promise<void>;
22
+ export {};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index.module-ad374d12.cjs"),m=require("axios"),u=require("react"),i=require("react/jsx-runtime");require("@r2wc/react-to-web-component");const l=require("react-router-dom");require("@mui/material");const c=r=>{const[t,o]=u.useState([]);return u.useEffect(()=>{m.get(`${r}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(s=>o(s.data)).catch(s=>{console.error("Getting user permission error:",s)})},[r]),t},a=r=>(t,o)=>{const s=c(r);return o?t.every(n=>s==null?void 0:s.includes(n)):t.some(n=>s==null?void 0:s.includes(n))},h=({baseUrl:r,accessWith:t,requireAll:o,children:s})=>a(r)(t,o)?i.jsx(i.Fragment,{children:s}):null,P=({accessWith:r,requireAll:t,baseUrl:o,unAuthorizedPath:s,children:n})=>a(o)(r,t)?i.jsx(i.Fragment,{children:n}):i.jsx(l.Navigate,{to:s,replace:!0});exports.AuthContext=e.AuthContext;exports.AuthProvider=e.AuthProvider;exports.ERROR_MESSAGE=e.ERROR_MESSAGE;exports.SaasThemeProvider=e.SaasThemeProvider;exports.TranslationProvider=e.TranslationProvider;exports.axiosInstance=e.axiosInstance;exports.color=e.color;exports.createCustomTheme=e.createCustomTheme;exports.handleErrorAxios=e.handleErrorAxios;exports.login=e.login;exports.logout=e.logout;exports.responseInterceptor=e.responseInterceptor;exports.search=e.search;exports.setFavicon=e.setFavicon;exports.translate=e.translate;exports.translationConfig=e.translationConfig;exports.useAuth=e.useAuth;exports.useCustomTranslation=e.useCustomTranslation;exports.useTheme=e.useTheme;exports.useTranslation=e.useTranslation$1;exports.HasPermission=h;exports.PermissionRoute=P;exports.getUseHasPermission=a;exports.useGetPermission=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index.module-f97db7a7.cjs"),m=require("axios"),u=require("react"),i=require("react/jsx-runtime");require("@r2wc/react-to-web-component");const l=require("react-router-dom");require("@mui/material");const c=s=>{const[t,o]=u.useState([]);return u.useEffect(()=>{m.get(`${s}/user-management/api/v1/users/my-account/permissions`,{withCredentials:!0}).then(r=>o(r.data)).catch(r=>{console.error("Getting user permission error:",r)})},[s]),t},a=s=>(t,o)=>{const r=c(s);return o?t.every(n=>r==null?void 0:r.includes(n)):t.some(n=>r==null?void 0:r.includes(n))},h=({baseUrl:s,accessWith:t,requireAll:o,children:r})=>a(s)(t,o)?i.jsx(i.Fragment,{children:r}):null,P=({accessWith:s,requireAll:t,baseUrl:o,unAuthorizedPath:r,children:n})=>a(o)(s,t)?i.jsx(i.Fragment,{children:n}):i.jsx(l.Navigate,{to:r,replace:!0});exports.AuthContext=e.AuthContext;exports.AuthProvider=e.AuthProvider;exports.ERROR_MESSAGE=e.ERROR_MESSAGE;exports.ErrorManager=e.ErrorManager;exports.SaasThemeProvider=e.SaasThemeProvider;exports.TranslationProvider=e.TranslationProvider;exports.axiosInstance=e.axiosInstance;exports.color=e.color;exports.createCustomTheme=e.createCustomTheme;exports.handleErrorAxios=e.handleErrorAxios;exports.login=e.login;exports.logout=e.logout;exports.responseInterceptor=e.responseInterceptor;exports.search=e.search;exports.setFavicon=e.setFavicon;exports.translate=e.translate;exports.translationConfig=e.translationConfig;exports.useAuth=e.useAuth;exports.useCustomTranslation=e.useCustomTranslation;exports.useTheme=e.useTheme;exports.useTranslation=e.useTranslation$1;exports.HasPermission=h;exports.PermissionRoute=P;exports.getUseHasPermission=a;exports.useGetPermission=c;
@@ -5,3 +5,4 @@ export * from './permissions';
5
5
  export * from './helpers';
6
6
  export * from './TranslationProvider';
7
7
  export * from '../theme';
8
+ export * from './error-logs';
@@ -1,7 +1,7 @@
1
- import { M as R, N as S, O as G, a1 as y, Z as F, a as H, c as I, $ as M, U as N, R as O, T as $, V as j, t as w, a0 as U, X as V, W as X, b as Y, u as Z, g as _, Y as b } from "../index.module-d7ed9e68.js";
1
+ import { M as R, N as S, O as G, a2 as M, a1 as y, Z as F, a as H, c as I, $ as N, U as O, R as $, T as j, V as w, t as U, a0 as V, X, W as Y, b as Z, u as _, g as b, Y as k } from "../index.module-5b976574.js";
2
2
  import u from "axios";
3
3
  import { useState as m, useEffect as c } from "react";
4
- import { jsx as a, Fragment as n } from "react/jsx-runtime";
4
+ import { jsx as o, Fragment as n } from "react/jsx-runtime";
5
5
  import "@r2wc/react-to-web-component";
6
6
  import { Navigate as l } from "react-router-dom";
7
7
  import "@mui/material";
@@ -17,45 +17,46 @@ const h = (e) => {
17
17
  }, i = (e) => (r, t) => {
18
18
  const s = h(e);
19
19
  return t ? r.every(
20
- (o) => s == null ? void 0 : s.includes(o)
20
+ (a) => s == null ? void 0 : s.includes(a)
21
21
  ) : r.some(
22
- (o) => s == null ? void 0 : s.includes(o)
22
+ (a) => s == null ? void 0 : s.includes(a)
23
23
  );
24
24
  }, T = ({
25
25
  baseUrl: e,
26
26
  accessWith: r,
27
27
  requireAll: t,
28
28
  children: s
29
- }) => i(e)(r, t) ? /* @__PURE__ */ a(n, { children: s }) : null, A = ({
29
+ }) => i(e)(r, t) ? /* @__PURE__ */ o(n, { children: s }) : null, E = ({
30
30
  accessWith: e,
31
31
  requireAll: r,
32
32
  baseUrl: t,
33
33
  unAuthorizedPath: s,
34
- children: o
35
- }) => i(t)(e, r) ? /* @__PURE__ */ a(n, { children: o }) : /* @__PURE__ */ a(l, { to: s, replace: !0 });
34
+ children: a
35
+ }) => i(t)(e, r) ? /* @__PURE__ */ o(n, { children: a }) : /* @__PURE__ */ o(l, { to: s, replace: !0 });
36
36
  export {
37
37
  R as AuthContext,
38
38
  S as AuthProvider,
39
39
  G as ERROR_MESSAGE,
40
+ M as ErrorManager,
40
41
  T as HasPermission,
41
- A as PermissionRoute,
42
+ E as PermissionRoute,
42
43
  y as SaasThemeProvider,
43
44
  F as TranslationProvider,
44
45
  H as axiosInstance,
45
46
  I as color,
46
- M as createCustomTheme,
47
+ N as createCustomTheme,
47
48
  i as getUseHasPermission,
48
- N as handleErrorAxios,
49
- O as login,
50
- $ as logout,
51
- j as responseInterceptor,
52
- w as search,
53
- U as setFavicon,
54
- V as translate,
55
- X as translationConfig,
56
- Y as useAuth,
57
- Z as useCustomTranslation,
49
+ O as handleErrorAxios,
50
+ $ as login,
51
+ j as logout,
52
+ w as responseInterceptor,
53
+ U as search,
54
+ V as setFavicon,
55
+ X as translate,
56
+ Y as translationConfig,
57
+ Z as useAuth,
58
+ _ as useCustomTranslation,
58
59
  h as useGetPermission,
59
- _ as useTheme,
60
- b as useTranslation
60
+ b as useTheme,
61
+ k as useTranslation
61
62
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ukpc-lib/react",
3
3
  "private": false,
4
- "version": "0.8.17",
4
+ "version": "0.9.0",
5
5
  "type": "module",
6
6
  "main": "./dist/",
7
7
  "module": "./dist/",
@@ -1,5 +1,5 @@
1
1
  import "../index-0de70dab.js";
2
- import { F as o, u as r } from "../index-7d101f8a.js";
2
+ import { F as o, u as r } from "../index-8d072e84.js";
3
3
  export {
4
4
  o as FavoriteMenu,
5
5
  r as updateFavoriteItems
@@ -1,5 +1,5 @@
1
1
  import "../index-0de70dab.js";
2
- import { G as e } from "../index-7d101f8a.js";
2
+ import { G as e } from "../index-8d072e84.js";
3
3
  export {
4
4
  e as GlobalMenu
5
5
  };
@@ -1,5 +1,5 @@
1
1
  import "../index-0de70dab.js";
2
- import { L as p, T as e } from "../index-7d101f8a.js";
2
+ import { L as p, T as e } from "../index-8d072e84.js";
3
3
  export {
4
4
  p as LanguageDropdown,
5
5
  e as TopBar
@@ -1,5 +1,5 @@
1
1
  import "../index-0de70dab.js";
2
- import { H as o, g as r } from "../index-7d101f8a.js";
2
+ import { H as o, g as r } from "../index-8d072e84.js";
3
3
  export {
4
4
  o as HasPermission,
5
5
  r as getUseHasPermission