@intra-mart/smartlime 2.0.0-dev.20241210 → 2.0.0-dev.20251017

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 (66) hide show
  1. package/lib/_shared/renderTarget.d.ts +11 -11
  2. package/lib/_shared/renderTarget.js +2 -2
  3. package/lib/index.d.ts +1 -0
  4. package/lib/index.js +1 -0
  5. package/lib/packages/Copilot/IMCopilotError.d.ts +4 -0
  6. package/lib/packages/Copilot/IMCopilotError.js +10 -0
  7. package/lib/packages/Copilot/hooks/index.d.ts +1 -0
  8. package/lib/packages/Copilot/hooks/index.js +1 -0
  9. package/lib/packages/Copilot/hooks/useAssistant/index.d.ts +47 -0
  10. package/lib/packages/Copilot/hooks/useAssistant/index.js +194 -0
  11. package/lib/packages/Copilot/hooks/useAssistant/jsonParse.d.ts +2 -0
  12. package/lib/packages/Copilot/hooks/useAssistant/jsonParse.js +18 -0
  13. package/lib/packages/Copilot/hooks/useAssistant/types.d.ts +52 -0
  14. package/lib/packages/Copilot/hooks/useAssistant/types.js +1 -0
  15. package/lib/packages/Fetch/index.d.ts +4 -2
  16. package/lib/packages/Fetch/index.js +1 -0
  17. package/lib/packages/Me/index.d.ts +3 -2
  18. package/lib/packages/Me/index.js +1 -1
  19. package/lib/packages/Me/type.d.ts +1 -0
  20. package/lib/packages/OAuth/Context.d.ts +13 -1
  21. package/lib/packages/OAuth/hooks/index.d.ts +1 -0
  22. package/lib/packages/OAuth/hooks/index.js +1 -0
  23. package/lib/packages/OAuth/hooks/useAuthInitError.d.ts +3 -0
  24. package/lib/packages/OAuth/hooks/useAuthInitError.js +24 -0
  25. package/lib/packages/OAuth/hooks/useAuthState.d.ts +1 -1
  26. package/lib/packages/OAuth/hooks/useAuthStateEffect.d.ts +1 -1
  27. package/lib/packages/OAuth/hooks/useStartAuth.d.ts +1 -1
  28. package/lib/packages/OAuth/index.d.ts +9 -13
  29. package/lib/packages/OAuth/index.js +72 -44
  30. package/lib/packages/Search/hooks/useDepartmentPostSearch.d.ts +2 -1
  31. package/lib/packages/Search/hooks/useDepartmentSearch.d.ts +2 -1
  32. package/lib/packages/Search/hooks/useDepartmentTopSearch.d.ts +2 -1
  33. package/lib/packages/Search/hooks/usePostSearch.d.ts +2 -1
  34. package/lib/packages/Search/hooks/usePublicGroupRoleSearch.d.ts +2 -1
  35. package/lib/packages/Search/hooks/usePublicGroupSearch.d.ts +2 -1
  36. package/lib/packages/Search/hooks/usePublicGroupTopSearch.d.ts +2 -1
  37. package/lib/packages/Search/hooks/useRoleSearch.d.ts +2 -1
  38. package/lib/packages/Search/hooks/useUserAdditionalInformationSearch.d.ts +2 -1
  39. package/lib/packages/Search/hooks/useUserSearch.d.ts +2 -1
  40. package/lib/packages/Search/index.d.ts +3 -2
  41. package/lib/packages/Search/index.js +1 -1
  42. package/lib/packages/Search/types.d.ts +2 -1
  43. package/lib/packages/Session/index.d.ts +2 -1
  44. package/lib/packages/Session/index.js +29 -24
  45. package/lib/packages/Smartlime/index.d.ts +2 -1
  46. package/lib/packages/Tenant/Context.d.ts +13 -5
  47. package/lib/packages/Tenant/constants.d.ts +2 -0
  48. package/lib/packages/Tenant/constants.js +4 -0
  49. package/lib/packages/Tenant/hooks/index.d.ts +2 -2
  50. package/lib/packages/Tenant/hooks/index.js +2 -2
  51. package/lib/packages/Tenant/hooks/useIMModules.d.ts +6 -0
  52. package/lib/packages/Tenant/hooks/useIMModules.js +79 -0
  53. package/lib/packages/Tenant/hooks/useIMModulesState.d.ts +2 -0
  54. package/lib/packages/Tenant/hooks/{useIMFetchModuleState.js → useIMModulesState.js} +3 -4
  55. package/lib/packages/Tenant/index.d.ts +4 -15
  56. package/lib/packages/Tenant/index.js +16 -83
  57. package/lib/packages/Tenant/modulesType.d.ts +1522 -2
  58. package/lib/packages/Tenant/modulesType.js +1522 -2
  59. package/lib/packages/WebView/InternalIMWebView.d.ts +1 -1
  60. package/lib/packages/WebView/InternalIMWebView.js +6 -6
  61. package/lib/packages/WebView/hooks/useHackSearchUI.d.ts +1 -1
  62. package/lib/packages/WebView/index.js +8 -8
  63. package/package.json +27 -32
  64. package/lib/packages/Tenant/hooks/useIMFetchModuleState.d.ts +0 -2
  65. package/lib/packages/Tenant/hooks/useIMModuleInfo.d.ts +0 -6
  66. package/lib/packages/Tenant/hooks/useIMModuleInfo.js +0 -13
@@ -1,12 +1,12 @@
1
1
  import { useContext, useEffect, useReducer, useRef } from 'react';
2
2
  import { Context as DefaultContext } from '../Context';
3
3
  import { IMTenantError } from '../IMTenantError';
4
- export const useIMFetchModuleState = (Context) => {
4
+ export const useIMModulesState = (Context) => {
5
5
  const initRef = useRef(true);
6
6
  const [, forceRender] = useReducer((s) => s + 1, 0);
7
7
  const tenantContext = useContext(Context || DefaultContext);
8
8
  if (tenantContext == null) {
9
- throw new IMTenantError('useIMFetchModuleState requires either a Context provide or an ancestor element with a IMTenantProvider.');
9
+ throw new IMTenantError('useIMModulesState requires either a Context provide or an ancestor element with a IMTenantProvider.');
10
10
  }
11
11
  if (initRef.current) {
12
12
  initRef.current = false;
@@ -17,6 +17,5 @@ export const useIMFetchModuleState = (Context) => {
17
17
  tenantContext.modulesStateRenderTarget.removeEventListener(forceRender);
18
18
  };
19
19
  }, []);
20
- const state = tenantContext.getFetchModuleState();
21
- return state;
20
+ return tenantContext.getModules();
22
21
  };
@@ -1,24 +1,13 @@
1
- import { Context as DefaultContext } from './Context';
2
- import { ModuleIds } from './modulesType';
1
+ import { JSX } from 'react';
2
+ import { Context as DefaultContext, IMModules } from './Context';
3
3
  interface IMTenantProps {
4
4
  children: JSX.Element;
5
5
  baseUrl: string;
6
6
  tenantId?: string;
7
7
  tenantContext?: typeof DefaultContext;
8
- useModuleInfo?: boolean;
9
8
  }
10
- export interface ModuleInfo<T extends ModuleIds[number]> {
11
- moduleKey: T;
12
- enabled: boolean;
13
- othes: unknown;
14
- }
15
- export type Moudles = {
16
- [key in ModuleIds[number]]: ModuleInfo<key>;
17
- };
18
- export type FetchModuleState = 'notRequired' | 'notFetched' | 'fetched';
19
9
  export interface ModuleState {
20
- fetchModuleState: FetchModuleState;
21
- modules?: Moudles;
10
+ modules?: IMModules;
22
11
  }
23
- export declare const IMTenant: ({ children, baseUrl, tenantId, tenantContext, useModuleInfo, }: IMTenantProps) => import("react").JSX.Element;
12
+ export declare const IMTenant: ({ children, baseUrl, tenantId, tenantContext, }: IMTenantProps) => JSX.Element;
24
13
  export {};
@@ -1,115 +1,48 @@
1
1
  import AsyncStorage from '@react-native-async-storage/async-storage';
2
2
  import { useCallback, useRef } from 'react';
3
3
  import { useRenderTarget } from '../../_shared/renderTarget';
4
- import { join } from '../../utils/path';
5
4
  import { Context as DefaultContext } from './Context';
6
- import { IMTenantError } from './IMTenantError';
7
- import { HYBRID_SSO_KEY, MODULE_IDS } from './modulesType';
5
+ import { createStorageKey } from './constants';
8
6
  const useGetBaseUrl = (baseUrl) => {
9
7
  return useCallback(() => baseUrl, [baseUrl]);
10
8
  };
11
9
  const useGetTenantId = (tenantId) => {
12
10
  return useCallback(() => tenantId, [tenantId]);
13
11
  };
14
- const createInitFetchModuleState = (useModuleInfo) => {
15
- return useModuleInfo ? 'notFetched' : 'notRequired';
16
- };
17
- const createStorageKey = (baseUrl, moduleKey) => {
18
- return `${baseUrl}_${moduleKey}`;
19
- };
20
- const saveModuleInfoStorage = async (storageKey, ModuleInfo) => {
21
- return await AsyncStorage.setItem(storageKey, JSON.stringify(ModuleInfo));
22
- };
23
- const deleteModuleInfoStorage = async (storageKey) => {
12
+ const deleteModuleStorage = async (storageKey) => {
24
13
  return await AsyncStorage.removeItem(storageKey);
25
14
  };
26
- const getModuleInfoStorage = async (storageKey) => {
27
- const state = await AsyncStorage.getItem(storageKey);
28
- if (state == null)
29
- return;
30
- const result = JSON.parse(state);
31
- return result;
32
- };
33
- const useFetchModuleStateRef = (renderTarget, useModuleInfo) => {
34
- const ref = useRef(createInitFetchModuleState(useModuleInfo));
15
+ const useModuleRef = (baseUrl, renderTarget) => {
16
+ const ref = useRef(null);
35
17
  const setter = useCallback((state, silent) => {
36
- if (!useModuleInfo)
37
- throw new IMTenantError('useModuleInfo is not enabled');
38
18
  if (ref.current === state)
39
19
  return;
40
20
  ref.current = state;
41
21
  if (!silent)
42
22
  renderTarget.dispatch();
43
23
  }, []);
44
- const getter = useCallback(() => ref.current, []);
45
- return [ref, setter, getter];
46
- };
47
- const useModuleInfoRef = (baseUrl, fetchModuleStateSetter, useModuleInfo) => {
48
- const ref = useRef();
49
- const setter = useCallback((state, silent) => {
50
- if (!useModuleInfo)
51
- throw new IMTenantError('useModuleInfo is not enabled');
52
- if (ref.current === state)
53
- return;
54
- ref.current = state;
55
- fetchModuleStateSetter('fetched', silent);
56
- }, [fetchModuleStateSetter, useModuleInfo]);
57
- const getter = useCallback(() => ref.current, []);
24
+ const getter = useCallback(() => (ref.current == null ? void 0 : ref.current), []);
58
25
  const destroy = useCallback(async () => {
59
- for (let i = 0; i < MODULE_IDS.length; i++) {
60
- const key = MODULE_IDS[i];
61
- if (key) {
62
- const storageKey = createStorageKey(baseUrl, key);
63
- await deleteModuleInfoStorage(storageKey);
64
- }
65
- }
66
- ref.current = undefined;
67
- fetchModuleStateSetter('notFetched');
68
- }, [fetchModuleStateSetter, baseUrl]);
26
+ const storageKey = createStorageKey(baseUrl);
27
+ await deleteModuleStorage(storageKey);
28
+ ref.current = null;
29
+ renderTarget.dispatch();
30
+ }, [baseUrl]);
69
31
  return [ref, setter, getter, destroy];
70
32
  };
71
- const createCheckHybridSSOUrl = (baseUrl) => {
72
- return join(baseUrl, '/im_hybrid_sso/logout');
73
- };
74
- const useFetchModuleInfo = (baseUrl, setModuleInfo) => {
75
- return useCallback(async () => {
76
- const hybridSSOUrl = createCheckHybridSSOUrl(baseUrl);
77
- const storageKey = createStorageKey(baseUrl, HYBRID_SSO_KEY);
78
- const storageState = await getModuleInfoStorage(storageKey);
79
- if (storageState) {
80
- setModuleInfo({
81
- [HYBRID_SSO_KEY]: storageState,
82
- });
83
- }
84
- else {
85
- const response = await fetch(hybridSSOUrl);
86
- const hasHyBridSSO = response.status !== 404;
87
- const state = {
88
- moduleKey: HYBRID_SSO_KEY,
89
- enabled: hasHyBridSSO,
90
- othes: {},
91
- };
92
- saveModuleInfoStorage(storageKey, state);
93
- setModuleInfo({ [HYBRID_SSO_KEY]: state });
94
- }
95
- }, [setModuleInfo, baseUrl]);
96
- };
97
- export const IMTenant = ({ children, baseUrl, tenantId, tenantContext, useModuleInfo, }) => {
33
+ export const IMTenant = ({ children, baseUrl, tenantId, tenantContext, }) => {
98
34
  const Context = tenantContext || DefaultContext;
99
- const contextRef = useRef();
35
+ const contextRef = useRef(null);
100
36
  const modulesStateRenderTarget = useRenderTarget();
101
37
  const getBaseUrl = useGetBaseUrl(baseUrl);
102
38
  const getTenantId = useGetTenantId(tenantId);
103
- const [, setFetchModuleState, getFetchModuleState] = useFetchModuleStateRef(modulesStateRenderTarget, useModuleInfo);
104
- const [, setModuleInfo, getModuleInfo, destroyModuleInfo] = useModuleInfoRef(baseUrl, setFetchModuleState, useModuleInfo);
105
- const fetchModuleInfo = useFetchModuleInfo(baseUrl, setModuleInfo);
39
+ const [, setModules, getModules, destroyModule] = useModuleRef(baseUrl, modulesStateRenderTarget);
106
40
  contextRef.current = {
107
41
  getBaseUrl,
108
42
  getTenantId,
109
- getFetchModuleState,
110
- getModuleInfo,
111
- destroyModuleInfo,
112
- fetchModuleInfo,
43
+ getModules,
44
+ setModules,
45
+ destroyModule,
113
46
  modulesStateRenderTarget,
114
47
  };
115
48
  return (<Context.Provider value={contextRef.current}>{children}</Context.Provider>);