@minimaltech/ra-core-infra 0.0.3-0 → 0.0.3-10

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 (81) hide show
  1. package/README.md +43 -4
  2. package/dist/base/applications/base.application.d.ts +2 -1
  3. package/dist/base/applications/base.application.js +2 -0
  4. package/dist/base/applications/base.application.js.map +1 -1
  5. package/dist/base/providers/base.provider.d.ts +1 -1
  6. package/dist/base/providers/base.provider.js +1 -1
  7. package/dist/base/providers/count-rest-data.provider.d.ts +1 -1
  8. package/dist/base/providers/count-rest-data.provider.js +3 -1
  9. package/dist/base/providers/count-rest-data.provider.js.map +1 -1
  10. package/dist/base/providers/default-auth.provider.d.ts +2 -2
  11. package/dist/base/providers/default-auth.provider.js +2 -3
  12. package/dist/base/providers/default-auth.provider.js.map +1 -1
  13. package/dist/base/providers/default-i18n.provider.d.ts +1 -1
  14. package/dist/base/providers/default-i18n.provider.js +1 -1
  15. package/dist/base/providers/default-rest-data.provider.d.ts +7 -3
  16. package/dist/base/providers/default-rest-data.provider.js +79 -16
  17. package/dist/base/providers/default-rest-data.provider.js.map +1 -1
  18. package/dist/base/services/base-crud.service.d.ts +1 -1
  19. package/dist/base/services/base-crud.service.js +1 -1
  20. package/dist/base/services/base.service.d.ts +1 -1
  21. package/dist/base/services/base.service.js +1 -1
  22. package/dist/base/services/default-auth.service.d.ts +1 -1
  23. package/dist/base/services/default-auth.service.js +1 -1
  24. package/dist/base/services/default-network-data.service.d.ts +13 -4
  25. package/dist/base/services/default-network-data.service.js +103 -44
  26. package/dist/base/services/default-network-data.service.js.map +1 -1
  27. package/dist/common/constants.d.ts +22 -0
  28. package/dist/common/constants.js +22 -0
  29. package/dist/common/constants.js.map +1 -1
  30. package/dist/common/keys.d.ts +1 -0
  31. package/dist/common/keys.js +1 -0
  32. package/dist/common/keys.js.map +1 -1
  33. package/dist/common/types.d.ts +29 -5
  34. package/dist/helpers/index.d.ts +1 -0
  35. package/dist/helpers/index.js +1 -0
  36. package/dist/helpers/index.js.map +1 -1
  37. package/dist/helpers/logger.helper.js +1 -1
  38. package/dist/helpers/networks/base-network-request.helper.d.ts +1 -1
  39. package/dist/helpers/networks/base-network-request.helper.js +1 -1
  40. package/dist/helpers/networks/fetcher/axios-fetcher.d.ts +1 -1
  41. package/dist/helpers/networks/fetcher/axios-fetcher.js +1 -1
  42. package/dist/helpers/networks/fetcher/node-fetcher.js +1 -1
  43. package/dist/helpers/socket-io-client.helper.d.ts +36 -0
  44. package/dist/helpers/socket-io-client.helper.js +84 -0
  45. package/dist/helpers/socket-io-client.helper.js.map +1 -0
  46. package/dist/ui/components/CoreRaApplication.js +2 -2
  47. package/dist/ui/context.d.ts +1 -1
  48. package/dist/ui/hooks/index.d.ts +2 -0
  49. package/dist/ui/hooks/index.js +2 -0
  50. package/dist/ui/hooks/index.js.map +1 -1
  51. package/dist/ui/hooks/redux/index.d.ts +2 -0
  52. package/dist/ui/hooks/redux/index.js +3 -0
  53. package/dist/ui/hooks/redux/index.js.map +1 -0
  54. package/dist/ui/hooks/redux/use-app-dispatch.d.ts +5 -0
  55. package/dist/ui/hooks/redux/use-app-dispatch.js +21 -0
  56. package/dist/ui/hooks/redux/use-app-dispatch.js.map +1 -0
  57. package/dist/ui/hooks/redux/use-app-selector.d.ts +5 -0
  58. package/dist/ui/hooks/redux/use-app-selector.js +17 -0
  59. package/dist/ui/hooks/redux/use-app-selector.js.map +1 -0
  60. package/dist/ui/hooks/use-application-context.js +1 -1
  61. package/dist/ui/hooks/use-debounce.js +2 -2
  62. package/dist/ui/hooks/use-injectable.d.ts +1 -1
  63. package/dist/ui/hooks/use-injectable.js +1 -1
  64. package/dist/ui/hooks/use-logout.d.ts +3 -0
  65. package/dist/ui/hooks/use-logout.js +74 -0
  66. package/dist/ui/hooks/use-logout.js.map +1 -0
  67. package/dist/ui/hooks/use-request-header-locale.d.ts +3 -0
  68. package/dist/ui/hooks/use-request-header-locale.js +17 -0
  69. package/dist/ui/hooks/use-request-header-locale.js.map +1 -0
  70. package/dist/ui/hooks/use-translate.d.ts +1 -1
  71. package/dist/ui/types.d.ts +3 -0
  72. package/dist/utilities/error.utility.d.ts +12 -0
  73. package/dist/utilities/error.utility.js +5 -1
  74. package/dist/utilities/error.utility.js.map +1 -1
  75. package/dist/utilities/file.utility.d.ts +1 -0
  76. package/dist/utilities/file.utility.js +9 -0
  77. package/dist/utilities/file.utility.js.map +1 -0
  78. package/dist/utilities/index.d.ts +1 -0
  79. package/dist/utilities/index.js +1 -0
  80. package/dist/utilities/index.js.map +1 -1
  81. package/package.json +7 -4
@@ -1,3 +1,4 @@
1
+ export * from './redux';
1
2
  export * from './use-application-context';
2
3
  export * from './use-autosave';
3
4
  export * from './use-before-unload';
@@ -6,6 +7,7 @@ export * from './use-copy-to-clipboard';
6
7
  export * from './use-debounce';
7
8
  export * from './use-document-title';
8
9
  export * from './use-injectable';
10
+ export * from './use-logout';
9
11
  export * from './use-sizer';
10
12
  export * from './use-translate';
11
13
  export * from './use-window-dimensions';
@@ -1,3 +1,4 @@
1
+ export * from './redux';
1
2
  export * from './use-application-context';
2
3
  export * from './use-autosave';
3
4
  export * from './use-before-unload';
@@ -6,6 +7,7 @@ export * from './use-copy-to-clipboard';
6
7
  export * from './use-debounce';
7
8
  export * from './use-document-title';
8
9
  export * from './use-injectable';
10
+ export * from './use-logout';
9
11
  export * from './use-sizer';
10
12
  export * from './use-translate';
11
13
  export * from './use-window-dimensions';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/hooks/index.tsx"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ui/hooks/index.tsx"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,yBAAyB,CAAC;AACxC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './use-app-dispatch';
2
+ export * from './use-app-selector';
@@ -0,0 +1,3 @@
1
+ export * from './use-app-dispatch';
2
+ export * from './use-app-selector';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/hooks/redux/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Dispatch, UnknownAction } from '@reduxjs/toolkit';
2
+ export declare const createAppDispatch: <D extends Dispatch<UnknownAction> = Dispatch<UnknownAction>>() => {
3
+ useAppDispatch: import("react-redux").UseDispatch<D>;
4
+ useMultipleAppDispatch: () => (...actions: Parameters<D>[0][]) => void;
5
+ };
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { useDispatch } from 'react-redux';
3
+ export const createAppDispatch = () => {
4
+ const useAppDispatch = useDispatch.withTypes();
5
+ const useMultipleAppDispatch = () => {
6
+ const dispatch = useAppDispatch();
7
+ const multipleDispatch = React.useCallback((...actions) => {
8
+ actions.forEach(action => {
9
+ if (action) {
10
+ dispatch(action);
11
+ }
12
+ });
13
+ }, [dispatch]);
14
+ return multipleDispatch;
15
+ };
16
+ return {
17
+ useAppDispatch,
18
+ useMultipleAppDispatch,
19
+ };
20
+ };
21
+ //# sourceMappingURL=use-app-dispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-app-dispatch.js","sourceRoot":"","sources":["../../../../src/ui/hooks/redux/use-app-dispatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAE7B,EAAE;IAEJ,MAAM,cAAc,GAAG,WAAW,CAAC,SAAS,EAAK,CAAC;IAGlD,MAAM,sBAAsB,GAAG,GAAG,EAAE;QAElC,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC;QAMlC,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW,CACxC,CAAC,GAAG,OAA6B,EAAE,EAAE;YACnC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBACvB,IAAI,MAAM,EAAE,CAAC;oBACX,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACnB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;QAGF,OAAO,gBAAgB,CAAC;IAC1B,CAAC,CAAC;IAEF,OAAO;QACL,cAAc;QACd,sBAAsB;KACvB,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare const createAppSelectors: <S>() => {
2
+ useAppSelector: import("react-redux").UseSelector<S>;
3
+ useShallowEqualSelector: <T>(selector: (state: S) => T) => T;
4
+ useDeepEqualSelector: <T>(selector: (state: S) => T) => T;
5
+ };
@@ -0,0 +1,17 @@
1
+ import isEqual from 'lodash/isEqual';
2
+ import { shallowEqual, useSelector } from 'react-redux';
3
+ export const createAppSelectors = () => {
4
+ const useAppSelector = useSelector.withTypes();
5
+ const useShallowEqualSelector = (selector) => {
6
+ return useAppSelector(selector, shallowEqual);
7
+ };
8
+ const useDeepEqualSelector = (selector) => {
9
+ return useAppSelector(selector, isEqual);
10
+ };
11
+ return {
12
+ useAppSelector,
13
+ useShallowEqualSelector,
14
+ useDeepEqualSelector,
15
+ };
16
+ };
17
+ //# sourceMappingURL=use-app-selector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-app-selector.js","sourceRoot":"","sources":["../../../../src/ui/hooks/redux/use-app-selector.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAM,EAAE;IAExC,MAAM,cAAc,GAAG,WAAW,CAAC,SAAS,EAAK,CAAC;IAGlD,MAAM,uBAAuB,GAAG,CAAI,QAAyB,EAAE,EAAE;QAC/D,OAAO,cAAc,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IAChD,CAAC,CAAC;IAGF,MAAM,oBAAoB,GAAG,CAAI,QAAyB,EAAE,EAAE;QAC5D,OAAO,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC,CAAC;IAEF,OAAO;QACL,cAAc;QACd,uBAAuB;QACvB,oBAAoB;KACrB,CAAC;AACJ,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { getError } from '@/utilities';
2
+ import { getError } from '../../utilities';
3
3
  import { ApplicationContext } from '../context';
4
4
  export const useApplicationContext = () => {
5
5
  const rs = React.useContext(ApplicationContext);
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { App } from '@/common/constants';
3
- import { isBrowser } from '@/utilities/boolean.utility';
2
+ import { App } from '../../common/constants';
3
+ import { isBrowser } from '../../utilities/boolean.utility';
4
4
  export const useDebounce = (params) => {
5
5
  const { value, delay, disabled } = params;
6
6
  const [debouncedValue, setDebouncedValue] = React.useState(value);
@@ -1,5 +1,5 @@
1
1
  import { Container } from '@venizia/ignis-inversion';
2
- import { CoreBindings, ValueOf } from '@/common';
2
+ import { CoreBindings, ValueOf } from '../../common';
3
3
  export interface IUseInjectableKeysOverrides {
4
4
  }
5
5
  export type TUseInjectableKeysDefault = Extract<ValueOf<typeof CoreBindings>, string>;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { getError } from '@/utilities';
2
+ import { getError } from '../../utilities';
3
3
  import { ApplicationContext } from '../context';
4
4
  export const useInjectable = (opts) => {
5
5
  const requestContainer = opts?.container;
@@ -0,0 +1,3 @@
1
+ export declare const useLogout: () => TLogout;
2
+ type TLogout = (params?: any, redirectTo?: string | false, redirectToCurrentLocationAfterLogin?: boolean) => Promise<any>;
3
+ export {};
@@ -0,0 +1,74 @@
1
+ import React from 'react';
2
+ import { useQueryClient } from '@tanstack/react-query';
3
+ import { removeDoubleSlashes, useAuthProvider, useBasename } from 'ra-core';
4
+ import { useLocation, useNavigate } from 'react-router-dom';
5
+ const defaultAuthParams = {
6
+ loginUrl: '/login',
7
+ afterLoginUrl: '/',
8
+ };
9
+ export const useLogout = () => {
10
+ const authProvider = useAuthProvider();
11
+ const queryClient = useQueryClient();
12
+ const navigate = useNavigate();
13
+ const navigateRef = React.useRef(navigate);
14
+ const location = useLocation();
15
+ const locationRef = React.useRef(location);
16
+ const basename = useBasename();
17
+ const loginUrl = removeDoubleSlashes(`${basename}/${defaultAuthParams.loginUrl}`);
18
+ React.useEffect(() => {
19
+ locationRef.current = location;
20
+ navigateRef.current = navigate;
21
+ }, [location, navigate]);
22
+ const logout = React.useCallback((params = {}, redirectFromCaller, redirectToCurrentLocationAfterLogin = true) => {
23
+ if (authProvider) {
24
+ return authProvider.logout(params).then(redirectFromLogout => {
25
+ if (redirectFromLogout === false || redirectFromCaller === false) {
26
+ queryClient.clear();
27
+ return;
28
+ }
29
+ const finalRedirectTo = redirectFromCaller || redirectFromLogout || loginUrl;
30
+ if (finalRedirectTo?.startsWith('http')) {
31
+ queryClient.clear();
32
+ window.location.href = finalRedirectTo;
33
+ return finalRedirectTo;
34
+ }
35
+ const redirectToParts = finalRedirectTo.split('?');
36
+ const newLocation = {
37
+ pathname: redirectToParts[0],
38
+ };
39
+ let newLocationOptions = {};
40
+ if (redirectToCurrentLocationAfterLogin &&
41
+ locationRef.current &&
42
+ locationRef.current.pathname) {
43
+ newLocationOptions = {
44
+ state: {
45
+ nextPathname: locationRef.current.pathname,
46
+ nextSearch: locationRef.current.search,
47
+ },
48
+ };
49
+ }
50
+ if (redirectToParts[1]) {
51
+ newLocation.search = redirectToParts[1];
52
+ }
53
+ setTimeout(() => {
54
+ navigateRef.current(newLocation, newLocationOptions);
55
+ queryClient.clear();
56
+ }, 0);
57
+ return redirectFromLogout;
58
+ });
59
+ }
60
+ else {
61
+ navigateRef.current({
62
+ pathname: loginUrl,
63
+ }, {
64
+ state: {
65
+ nextPathname: locationRef.current && locationRef.current.pathname,
66
+ },
67
+ });
68
+ queryClient.clear();
69
+ return Promise.resolve();
70
+ }
71
+ }, [authProvider, loginUrl, queryClient]);
72
+ return logout;
73
+ };
74
+ //# sourceMappingURL=use-logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-logout.js","sourceRoot":"","sources":["../../../src/ui/hooks/use-logout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAQ,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,iBAAiB,GAAG;IACxB,QAAQ,EAAE,QAAQ;IAClB,aAAa,EAAE,GAAG;CACnB,CAAC;AAKF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAY,EAAE;IACrC,MAAM,YAAY,GAAG,eAAe,EAA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,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const useRequestHeaderLocale: (params?: {
2
+ key?: string;
3
+ }) => void;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { useLocaleState } from 'ra-core';
3
+ import { HeaderConsts } from '../../common/constants';
4
+ import { CoreBindings } from '../../common/keys';
5
+ import { useInjectable } from './use-injectable';
6
+ export const useRequestHeaderLocale = (params) => {
7
+ const key = params?.key || HeaderConsts.X_LOCALE;
8
+ const [locale] = useLocaleState();
9
+ const defaultRestDataProvider = useInjectable({
10
+ key: CoreBindings.DEFAULT_REST_DATA_PROVIDER,
11
+ });
12
+ React.useEffect(() => {
13
+ defaultRestDataProvider.getNetworkService().setHeaders({ [key]: locale });
14
+ return () => { };
15
+ }, [defaultRestDataProvider, key, locale]);
16
+ };
17
+ //# sourceMappingURL=use-request-header-locale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-request-header-locale.js","sourceRoot":"","sources":["../../../src/ui/hooks/use-request-header-locale.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAKjD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,MAAyB,EAAE,EAAE;IAClE,MAAM,GAAG,GAAG,MAAM,EAAE,GAAG,IAAI,YAAY,CAAC,QAAQ,CAAC;IAGjD,MAAM,CAAC,MAAM,CAAC,GAAG,cAAc,EAAE,CAAC;IAGlC,MAAM,uBAAuB,GAAG,aAAa,CAA0B;QACrE,GAAG,EAAE,YAAY,CAAC,0BAA0B;KAC7C,CAAC,CAAC;IAGH,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,uBAAuB,CAAC,iBAAiB,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QAE1E,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;AAC7C,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { AnyType, englishMessages, TFullPaths } from '@/common';
1
+ import { AnyType, englishMessages, TFullPaths } from '../../common';
2
2
  export interface IUseTranslateKeysOverrides {
3
3
  }
4
4
  export type TUseTranslateKeysDefault = TFullPaths<typeof englishMessages>;
@@ -12,3 +12,6 @@ export interface IApplication extends Omit<CoreAdminProps, 'children'> {
12
12
  routes: Array<RouteProps>;
13
13
  };
14
14
  }
15
+ export interface SyncFC<P = {}> {
16
+ (props: P): React.ReactNode;
17
+ }
@@ -2,11 +2,19 @@ export declare class ApplicationError extends Error {
2
2
  statusCode: number;
3
3
  messageCode?: string;
4
4
  payload?: any;
5
+ extra?: {
6
+ messageArgs?: any;
7
+ [key: string]: any;
8
+ };
5
9
  constructor(opts: {
6
10
  statusCode?: number;
7
11
  messageCode?: string;
8
12
  message: string;
9
13
  payload?: any;
14
+ extra?: {
15
+ messageArgs?: any;
16
+ [key: string]: any;
17
+ };
10
18
  });
11
19
  }
12
20
  export declare const getError: (opts: {
@@ -14,5 +22,9 @@ export declare const getError: (opts: {
14
22
  messageCode?: string;
15
23
  message: string;
16
24
  payload?: any;
25
+ extra?: {
26
+ messageArgs?: any;
27
+ [key: string]: any;
28
+ };
17
29
  }) => ApplicationError;
18
30
  export declare const getClientError: (e: unknown) => ApplicationError;
@@ -2,12 +2,14 @@ export class ApplicationError extends Error {
2
2
  statusCode;
3
3
  messageCode;
4
4
  payload;
5
+ extra;
5
6
  constructor(opts) {
6
- const { message, messageCode, statusCode = 400, payload } = opts;
7
+ const { message, messageCode, statusCode = 400, payload, extra } = opts;
7
8
  super(message);
8
9
  this.statusCode = statusCode;
9
10
  this.messageCode = messageCode;
10
11
  this.payload = payload;
12
+ this.extra = extra;
11
13
  }
12
14
  }
13
15
  export const getError = (opts) => {
@@ -17,8 +19,10 @@ export const getError = (opts) => {
17
19
  export const getClientError = (e) => {
18
20
  if (e instanceof ApplicationError) {
19
21
  return new ApplicationError({
22
+ statusCode: e.statusCode,
20
23
  messageCode: e?.messageCode ?? e.message,
21
24
  message: e.message,
25
+ extra: e.extra,
22
26
  });
23
27
  }
24
28
  if (e instanceof Error) {
@@ -1 +1 @@
1
- {"version":3,"file":"error.utility.js","sourceRoot":"","sources":["../../src/utilities/error.utility.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,UAAU,CAAS;IACnB,WAAW,CAAU;IACrB,OAAO,CAAO;IAEd,YAAY,IAAmF;QAC7F,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,UAAU,GAAG,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACjE,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAKxB,EAAE,EAAE;IACH,MAAM,KAAK,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAU,EAAE,EAAE;IAC3C,IAAI,CAAC,YAAY,gBAAgB,EAAE,CAAC;QAClC,OAAO,IAAI,gBAAgB,CAAC;YAC1B,WAAW,EAAE,CAAC,EAAE,WAAW,IAAI,CAAC,CAAC,OAAO;YACxC,OAAO,EAAE,CAAC,CAAC,OAAO;SACnB,CAAC,CAAC;IACL,CAAC;I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AAC,CAAC,OAAO;YACxC,OAAO,EAAE,CAAC,CAAC,OAAO;YAClB,KAAK,EAAE,CAAC,CAAC,KAAK;SACf,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;QACvB,OAAO,IAAI,gBAAgB,CAAC;YAC1B,WAAW,EAAE,CAAC,CAAC,OAAO;YACtB,OAAO,EAAE,CAAC,CAAC,OAAO;SACnB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,IAAI,gBAAgB,CAAC;QAC1B,WAAW,EAAE,GAAG,CAAC,EAAE;QACnB,OAAO,EAAE,GAAG,CAAC,EAAE;KAChB,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const blobToBase64: (blob: Blob) => Promise<string>;
@@ -0,0 +1,9 @@
1
+ export const blobToBase64 = (blob) => {
2
+ return new Promise((resolve, reject) => {
3
+ const reader = new FileReader();
4
+ reader.onloadend = () => resolve(reader.result);
5
+ reader.onerror = reject;
6
+ reader.readAsDataURL(blob);
7
+ });
8
+ };
9
+ //# sourceMappingURL=file.utility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.utility.js","sourceRoot":"","sources":["../../src/utilities/file.utility.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAU,EAAmB,EAAE;IAC1D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAC;QAC1D,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC;QACxB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
1
  export * from './boolean.utility';
2
2
  export * from './error.utility';
3
+ export * from './file.utility';
3
4
  export * from './parse.utility';
4
5
  export * from './url.utility';
@@ -1,5 +1,6 @@
1
1
  export * from './boolean.utility';
2
2
  export * from './error.utility';
3
+ export * from './file.utility';
3
4
  export * from './parse.utility';
4
5
  export * from './url.utility';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minimaltech/ra-core-infra",
3
- "version": "0.0.3-0",
3
+ "version": "0.0.3-10",
4
4
  "description": "Minimal Technology - ReactJS Core Infrastructure",
5
5
  "keywords": [
6
6
  "web",
@@ -78,6 +78,7 @@
78
78
  },
79
79
  "dependencies": {
80
80
  "@reduxjs/toolkit": "^2.9.1",
81
+ "@tanstack/react-query": "^5.99.0",
81
82
  "ra-i18n-polyglot": "^5.12.1",
82
83
  "react-router-dom": "^7.9.4"
83
84
  },
@@ -86,8 +87,8 @@
86
87
  "@size-limit/preset-small-lib": "^11.2.0",
87
88
  "@types/lodash": "^4.14.194",
88
89
  "@types/node": "^22.10.5",
89
- "@types/react": "^18.3.12",
90
- "@types/react-dom": "^18.0.11",
90
+ "@types/react": "^19",
91
+ "@types/react-dom": "^19",
91
92
  "eslint": "^9.38.0",
92
93
  "eslint-plugin-react": "^7.37.5",
93
94
  "eslint-plugin-react-hooks": "^7.0.1",
@@ -110,7 +111,9 @@
110
111
  "ra-core": ">=5.12.2",
111
112
  "react": ">=18.0",
112
113
  "react-dom": ">=18.0",
113
- "react-redux": "^9.1.2"
114
+ "react-redux": "^9.1.2",
115
+ "reflect-metadata": "^0.2.2",
116
+ "socket.io-client": "^4.8.3"
114
117
  },
115
118
  "size-limit": [
116
119
  {