@monorise/react 1.0.1 → 1.0.2

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 (38) hide show
  1. package/dist/actions/config.action.d.ts +10 -0
  2. package/dist/actions/config.action.d.ts.map +1 -0
  3. package/dist/actions/config.action.js +31 -0
  4. package/dist/actions/config.action.js.map +1 -0
  5. package/dist/actions/core.action.d.ts.map +1 -1
  6. package/dist/actions/core.action.js +2 -3
  7. package/dist/actions/core.action.js.map +1 -1
  8. package/dist/index.d.ts +388 -24
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +12 -8
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.jsx +48 -0
  13. package/dist/index.jsx.map +1 -0
  14. package/dist/services/core.service.d.ts +2 -1
  15. package/dist/services/core.service.d.ts.map +1 -1
  16. package/dist/services/core.service.js +9 -10
  17. package/dist/services/core.service.js.map +1 -1
  18. package/dist/store/monorise.store.d.ts +9 -3
  19. package/dist/store/monorise.store.d.ts.map +1 -1
  20. package/dist/store/monorise.store.js +3 -11
  21. package/dist/store/monorise.store.js.map +1 -1
  22. package/index.ts +18 -4
  23. package/package.json +6 -4
  24. package/actions/app.action.ts +0 -218
  25. package/actions/auth.action.ts +0 -71
  26. package/actions/core.action.ts +0 -878
  27. package/lib/api.tsx +0 -132
  28. package/lib/config.ts +0 -36
  29. package/lib/constant.ts +0 -1
  30. package/lib/entity.ts +0 -81
  31. package/lib/utils.ts +0 -12
  32. package/services/auth.service.ts +0 -59
  33. package/services/core.service.ts +0 -416
  34. package/services/filestore.service.ts +0 -136
  35. package/store/monorise.store.ts +0 -111
  36. package/types/api.type.ts +0 -57
  37. package/types/axios.type.ts +0 -14
  38. package/types/monorise.type.ts +0 -8
@@ -1,71 +0,0 @@
1
- import type { Entity } from '@monorise/base';
2
- import { produce } from 'immer';
3
- import type { AuthService } from '../services/auth.service';
4
- import type { MonoriseStore } from '../store/monorise.store';
5
-
6
- const initAuthActions = (store: MonoriseStore, authService: AuthService) => {
7
- const requestLogin = async (
8
- entityType: Entity,
9
- payload: { email: string },
10
- ) => {
11
- const { data } = await authService.requestLoginMagicLink(
12
- entityType,
13
- payload,
14
- );
15
-
16
- return data;
17
- };
18
-
19
- const useProfile = <T extends Record<string, unknown>>(): T & {
20
- displayName: string;
21
- email: string;
22
- accountId: string;
23
- impersonatorId?: string;
24
- } => {
25
- const profile = store((state) => state.auth.profile);
26
-
27
- return profile as T & typeof profile;
28
- };
29
-
30
- const getProfile = async () => {
31
- const {
32
- data: { displayName, email, accountId, ...rest },
33
- } = await authService.getSessionProfile();
34
-
35
- store.setState(
36
- produce((state) => {
37
- state.auth.profile = {
38
- displayName,
39
- email,
40
- accountId,
41
- ...rest,
42
- };
43
- }),
44
- undefined,
45
- 'mr/auth/get-profile',
46
- );
47
- };
48
-
49
- const useIsUnauthorized = () => {
50
- return store((state) => state.auth.isUnauthorized);
51
- };
52
-
53
- const setIsUnauthorized = (isUnauthorized: boolean) =>
54
- store.setState(
55
- produce((state) => {
56
- state.auth.isUnauthorized = isUnauthorized;
57
- }),
58
- );
59
-
60
- return {
61
- requestLogin,
62
- useProfile,
63
- getProfile,
64
- useIsUnauthorized,
65
- setIsUnauthorized,
66
- };
67
- };
68
-
69
- export { initAuthActions };
70
-
71
- export type AuthActions = ReturnType<typeof initAuthActions>;