@intra-mart/smartlime 2.0.0-dev.20241125 → 2.0.0-rc.20241226

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 (52) hide show
  1. package/eslint.config.mjs +50 -0
  2. package/lib/_shared/renderTarget.d.ts +1 -1
  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/Context.d.ts +0 -1
  18. package/lib/packages/Me/index.d.ts +0 -1
  19. package/lib/packages/OAuth/Context.d.ts +0 -1
  20. package/lib/packages/OAuth/hooks/index.d.ts +1 -1
  21. package/lib/packages/OAuth/hooks/index.js +1 -1
  22. package/lib/packages/OAuth/hooks/useAuthInitError.d.ts +3 -0
  23. package/lib/packages/OAuth/hooks/useAuthInitError.js +24 -0
  24. package/lib/packages/OAuth/index.d.ts +0 -1
  25. package/lib/packages/OAuth/index.js +9 -9
  26. package/lib/packages/Search/Context.d.ts +0 -1
  27. package/lib/packages/Search/hooks/useDepartmentPostSearch.d.ts +2 -1
  28. package/lib/packages/Search/hooks/useDepartmentSearch.d.ts +2 -1
  29. package/lib/packages/Search/hooks/useDepartmentTopSearch.d.ts +2 -1
  30. package/lib/packages/Search/hooks/useIMSearch.d.ts +1 -1
  31. package/lib/packages/Search/hooks/usePostSearch.d.ts +2 -1
  32. package/lib/packages/Search/hooks/usePublicGroupRoleSearch.d.ts +2 -1
  33. package/lib/packages/Search/hooks/usePublicGroupSearch.d.ts +2 -1
  34. package/lib/packages/Search/hooks/usePublicGroupTopSearch.d.ts +2 -1
  35. package/lib/packages/Search/hooks/useRoleSearch.d.ts +2 -1
  36. package/lib/packages/Search/hooks/useUserAdditionalInformationSearch.d.ts +2 -1
  37. package/lib/packages/Search/hooks/useUserSearch.d.ts +2 -1
  38. package/lib/packages/Search/index.d.ts +0 -1
  39. package/lib/packages/Search/types.d.ts +2 -1
  40. package/lib/packages/Session/Context.d.ts +0 -1
  41. package/lib/packages/Session/hooks/useSession.d.ts +0 -1
  42. package/lib/packages/Session/hooks/useSessionState.d.ts +0 -1
  43. package/lib/packages/Session/index.d.ts +0 -1
  44. package/lib/packages/Smartlime/NotSearchPropError.d.ts +0 -1
  45. package/lib/packages/Smartlime/index.d.ts +0 -1
  46. package/lib/packages/Tenant/Context.d.ts +0 -1
  47. package/lib/packages/Tenant/index.d.ts +0 -1
  48. package/lib/packages/WebView/hooks/useHackSearchUI.d.ts +0 -1
  49. package/lib/utils/mergeRef.d.ts +1 -2
  50. package/package.json +23 -27
  51. package/lib/packages/OAuth/hooks/useAuthError.d.ts +0 -2
  52. package/lib/packages/OAuth/hooks/useAuthError.js +0 -15
@@ -0,0 +1,50 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ import js from '@eslint/js';
5
+ import { FlatCompat } from '@eslint/eslintrc';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = path.dirname(__filename);
9
+ const compat = new FlatCompat({
10
+ baseDirectory: __dirname,
11
+ recommendedConfig: js.configs.recommended,
12
+ allConfig: js.configs.all,
13
+ });
14
+
15
+ export default [
16
+ ...compat.extends(
17
+ 'plugin:react/recommended',
18
+ 'plugin:@typescript-eslint/recommended',
19
+ 'prettier'
20
+ ),
21
+ {
22
+ languageOptions: {
23
+ parser: tsParser,
24
+ ecmaVersion: 2020,
25
+ sourceType: 'module',
26
+
27
+ parserOptions: {
28
+ ecmaFeatures: {
29
+ jsx: true,
30
+ },
31
+ },
32
+ },
33
+
34
+ settings: {
35
+ react: {
36
+ version: 'detect',
37
+ },
38
+ },
39
+
40
+ rules: {
41
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
42
+ '@typescript-eslint/ban-ts-comment': 'off',
43
+ '@typescript-eslint/no-empty-function': 'off',
44
+ 'react/react-in-jsx-scope': 'off',
45
+ 'react/prop-types': 'off',
46
+ 'react/display-name': 'off',
47
+ 'react/jsx-key': 'off',
48
+ },
49
+ },
50
+ ];
@@ -2,7 +2,7 @@ type ForceRender<T> = (args?: T) => void;
2
2
  export declare const createRenderTarget: <T = undefined>() => {
3
3
  addEventListener: (callback: ForceRender<T>) => void;
4
4
  removeEventListener: (callback: ForceRender<T>) => void;
5
- dispatch: (args?: T | undefined) => void;
5
+ dispatch: (args?: T) => void;
6
6
  };
7
7
  export type CreateRenderTarget<T = undefined> = typeof createRenderTarget<T>;
8
8
  export type RenderTarget<T = undefined> = ReturnType<CreateRenderTarget<T>>;
package/lib/index.d.ts CHANGED
@@ -13,3 +13,4 @@ export { IMSearch } from './packages/Search';
13
13
  export * from './packages/Search/hooks';
14
14
  export { IMWebView } from './packages/WebView';
15
15
  export * from './packages/WebView/hooks';
16
+ export * from './packages/Copilot/hooks';
package/lib/index.js CHANGED
@@ -16,3 +16,4 @@ export { IMSearch } from './packages/Search';
16
16
  export * from './packages/Search/hooks';
17
17
  export { IMWebView } from './packages/WebView';
18
18
  export * from './packages/WebView/hooks';
19
+ export * from './packages/Copilot/hooks';
@@ -0,0 +1,4 @@
1
+ export declare const errorType = "IMCopilotError";
2
+ export declare class IMCopilotError extends Error {
3
+ constructor(message: string, options?: ErrorOptions);
4
+ }
@@ -0,0 +1,10 @@
1
+ export const errorType = 'IMCopilotError';
2
+ export class IMCopilotError extends Error {
3
+ constructor(message, options) {
4
+ super(message, options);
5
+ if (Error.captureStackTrace) {
6
+ Error.captureStackTrace(this, IMCopilotError);
7
+ }
8
+ this.name = errorType;
9
+ }
10
+ }
@@ -0,0 +1 @@
1
+ export * from './useAssistant';
@@ -0,0 +1 @@
1
+ export * from './useAssistant';
@@ -0,0 +1,47 @@
1
+ import { AssistantHistory, AssistantMetaData, AssistantRequest, ResponseMessage } from './types';
2
+ export interface AssistantSuccess {
3
+ type: 'success';
4
+ }
5
+ export interface AssistantError {
6
+ type: 'error';
7
+ error: Error;
8
+ }
9
+ export interface DeleteThreadSuccess {
10
+ type: 'success';
11
+ }
12
+ export interface DeleteThreadError {
13
+ type: 'error';
14
+ error: Error;
15
+ }
16
+ export interface GetAssistantMetaDataSuccess<T = unknown> {
17
+ type: 'success';
18
+ metaData: AssistantMetaData<T>;
19
+ }
20
+ export interface GetAssistantMetaDataError {
21
+ type: 'error';
22
+ error: Error;
23
+ }
24
+ export interface GetAssistantsMetaDataSuccess<T = unknown> {
25
+ type: 'success';
26
+ metaDataList: AssistantMetaData<T>[];
27
+ }
28
+ export interface GetAssistantsMetaDataError {
29
+ type: 'error';
30
+ error: Error;
31
+ }
32
+ export interface GetAssistantHistorySuccess<T = unknown> {
33
+ type: 'success';
34
+ history: AssistantHistory<T>[];
35
+ }
36
+ export interface GetAssistantHistoryError {
37
+ type: 'error';
38
+ error: Error;
39
+ }
40
+ export type AssistantCallback = (message: ResponseMessage, finish: boolean) => void;
41
+ export declare const useAssistantt: (assistantId: string, threadId?: string) => {
42
+ run: (message: AssistantRequest, callback: AssistantCallback) => Promise<AssistantSuccess | AssistantError>;
43
+ deleteThread: () => Promise<DeleteThreadSuccess | DeleteThreadError>;
44
+ getAssistantMetaData: <T = unknown>() => Promise<GetAssistantMetaDataSuccess<T> | GetAssistantMetaDataError>;
45
+ getAssistantsMetaData: <T = unknown>() => Promise<GetAssistantsMetaDataSuccess<T> | GetAssistantsMetaDataError>;
46
+ getThreadHistory: <T = unknown>() => Promise<GetAssistantHistorySuccess<T> | GetAssistantHistoryError>;
47
+ };
@@ -0,0 +1,194 @@
1
+ import { randomUUID } from 'expo-crypto';
2
+ import { useMemo } from 'react';
3
+ import { join } from '../../../../utils/path';
4
+ import { useIMFetch } from '../../../Fetch';
5
+ import { IMCopilotError } from '../../IMCopilotError';
6
+ import { jsonParse } from './jsonParse';
7
+ const hasFinishMessage = (message) => {
8
+ if (Object.hasOwn(message, 'finishReason'))
9
+ return true;
10
+ return false;
11
+ };
12
+ const isFinishMessage = (message) => {
13
+ return message.finishReason === 'stop' ? true : false;
14
+ };
15
+ const ASSISTANT_PATH = 'api/copilot/assistant';
16
+ const DELETE_PATH = 'api/copilot/message/history';
17
+ const ASSISTANT_METADATA_PATH = 'api/copilot/assistant';
18
+ const ASSISTANTS_METADATA_PATH = 'api/copilot/assistants';
19
+ const ASSISTANT_HISTORY_PATH = 'api/copilot/message/history';
20
+ export const useAssistantt = (assistantId, threadId) => {
21
+ const imFetch = useIMFetch();
22
+ const intternalThreadId = useMemo(() => (threadId ? threadId : randomUUID()), [threadId]);
23
+ const run = async (message, callback) => {
24
+ try {
25
+ const assistantUrl = join(ASSISTANT_PATH, assistantId);
26
+ const response = await imFetch(assistantUrl, {
27
+ method: 'POST',
28
+ headers: {
29
+ 'Content-Type': 'application/json',
30
+ // Accept: 'text/event-stream',
31
+ },
32
+ body: JSON.stringify({
33
+ threadId: intternalThreadId,
34
+ message: message.message,
35
+ additional: '',
36
+ }),
37
+ });
38
+ if (response.status !== 200) {
39
+ throw new Error('Proofread API Error');
40
+ }
41
+ if (!response.body) {
42
+ throw new Error('ReadableStream not supported in this environment');
43
+ }
44
+ const reader = response.body.getReader();
45
+ const decoder = new TextDecoder();
46
+ while (true) {
47
+ const { done, value } = await reader.read();
48
+ if (done) {
49
+ break;
50
+ }
51
+ const jsonText = decoder.decode(value, { stream: true });
52
+ const jsonList = jsonParse(jsonText);
53
+ jsonList.forEach((json) => {
54
+ if (hasFinishMessage(json)) {
55
+ const message = json.message;
56
+ const isFinish = isFinishMessage(json);
57
+ callback(message, isFinish);
58
+ }
59
+ else {
60
+ console.warn('Unexpected message', json);
61
+ }
62
+ });
63
+ }
64
+ return {
65
+ type: 'success',
66
+ };
67
+ }
68
+ catch (e) {
69
+ if (e instanceof Error) {
70
+ return {
71
+ type: 'error',
72
+ error: new IMCopilotError('Exception thrown while running the assistant.', { cause: e }),
73
+ };
74
+ }
75
+ throw e;
76
+ }
77
+ };
78
+ const deleteThread = async () => {
79
+ try {
80
+ const deleteThreadUrl = join(DELETE_PATH, intternalThreadId);
81
+ const response = await imFetch(deleteThreadUrl, {
82
+ method: 'DELETE',
83
+ headers: {
84
+ 'Content-Type': 'application/json',
85
+ },
86
+ });
87
+ if (response.status !== 200) {
88
+ throw new Error('Proofread API Error');
89
+ }
90
+ return {
91
+ type: 'success',
92
+ };
93
+ }
94
+ catch (e) {
95
+ if (e instanceof Error) {
96
+ return {
97
+ type: 'error',
98
+ error: new IMCopilotError('Exception thrown while attempting to delete the thread.', { cause: e }),
99
+ };
100
+ }
101
+ throw e;
102
+ }
103
+ };
104
+ const getAssistantMetaData = async () => {
105
+ try {
106
+ const metaDataUrl = join(ASSISTANT_METADATA_PATH, assistantId);
107
+ const response = await imFetch(metaDataUrl, {
108
+ method: 'GET',
109
+ headers: {
110
+ 'Content-Type': 'application/json',
111
+ },
112
+ });
113
+ if (response.status !== 200) {
114
+ throw new Error('Proofread API Error');
115
+ }
116
+ const json = await response.json();
117
+ return {
118
+ type: 'success',
119
+ metaData: json.data,
120
+ };
121
+ }
122
+ catch (e) {
123
+ if (e instanceof Error) {
124
+ return {
125
+ type: 'error',
126
+ error: new IMCopilotError('Exception thrown while attempting to get metadata.', { cause: e }),
127
+ };
128
+ }
129
+ throw e;
130
+ }
131
+ };
132
+ const getAssistantsMetaData = async () => {
133
+ try {
134
+ const response = await imFetch(ASSISTANTS_METADATA_PATH, {
135
+ method: 'GET',
136
+ headers: {
137
+ 'Content-Type': 'application/json',
138
+ },
139
+ });
140
+ if (response.status !== 200) {
141
+ throw new Error('Proofread API Error');
142
+ }
143
+ const json = await response.json();
144
+ return {
145
+ type: 'success',
146
+ metaDataList: json.data,
147
+ };
148
+ }
149
+ catch (e) {
150
+ if (e instanceof Error) {
151
+ return {
152
+ type: 'error',
153
+ error: new IMCopilotError('Exception thrown while attempting to get metadata.', { cause: e }),
154
+ };
155
+ }
156
+ throw e;
157
+ }
158
+ };
159
+ const getThreadHistory = async () => {
160
+ try {
161
+ const historyUrl = join(ASSISTANT_HISTORY_PATH, intternalThreadId);
162
+ const response = await imFetch(historyUrl, {
163
+ method: 'GET',
164
+ headers: {
165
+ 'Content-Type': 'application/json',
166
+ },
167
+ });
168
+ if (response.status !== 200) {
169
+ throw new Error('Proofread API Error');
170
+ }
171
+ const json = await response.json();
172
+ return {
173
+ type: 'success',
174
+ history: json.data,
175
+ };
176
+ }
177
+ catch (e) {
178
+ if (e instanceof Error) {
179
+ return {
180
+ type: 'error',
181
+ error: new IMCopilotError('Exception thrown while attempting to get history.', { cause: e }),
182
+ };
183
+ }
184
+ throw e;
185
+ }
186
+ };
187
+ return {
188
+ run,
189
+ deleteThread,
190
+ getAssistantMetaData,
191
+ getAssistantsMetaData,
192
+ getThreadHistory,
193
+ };
194
+ };
@@ -0,0 +1,2 @@
1
+ import { AssistantResponse } from './types';
2
+ export declare const jsonParse: (text: string) => AssistantResponse[];
@@ -0,0 +1,18 @@
1
+ export const jsonParse = (text) => {
2
+ const result = [];
3
+ try {
4
+ const json = JSON.parse(text);
5
+ result.push(json);
6
+ return result;
7
+ }
8
+ catch {
9
+ const jsonLines = text.split('\n');
10
+ for (const jsonLine of jsonLines) {
11
+ if (jsonLine !== '') {
12
+ const json = JSON.parse(jsonLine);
13
+ result.push(json);
14
+ }
15
+ }
16
+ return result;
17
+ }
18
+ };
@@ -0,0 +1,52 @@
1
+ export interface AssistantMetaData<T = unknown> {
2
+ assistantClass: string;
3
+ assistantType: string;
4
+ description: string;
5
+ name: string;
6
+ parameter: T;
7
+ listEnable: boolean;
8
+ storeMessage: boolean;
9
+ }
10
+ export interface AssistantHistory<T = unknown> {
11
+ role: string;
12
+ contents: string;
13
+ toolCalls: [
14
+ {
15
+ id: string;
16
+ type: string;
17
+ function: {
18
+ name: string;
19
+ arguments: string;
20
+ };
21
+ }
22
+ ];
23
+ additional: T[];
24
+ }
25
+ export interface ResponseMessage {
26
+ role: string;
27
+ contents: string | null;
28
+ toolCalls: unknown | null;
29
+ additional: unknown | null;
30
+ }
31
+ export interface AssistantResponse {
32
+ finishReason?: null | 'stop';
33
+ message: ResponseMessage;
34
+ }
35
+ export interface RequestMessage {
36
+ role: string;
37
+ contents: string | null;
38
+ toolCalls?: unknown;
39
+ additional?: unknown;
40
+ }
41
+ export interface AssistantRequest {
42
+ message: RequestMessage;
43
+ }
44
+ export interface AssistantMetaDataResponse<T = unknown> {
45
+ data: AssistantMetaData<T>;
46
+ }
47
+ export interface AssistantsMetaDataResponse<T = unknown> {
48
+ data: AssistantMetaData<T>[];
49
+ }
50
+ export interface AssistantHistoryResponse<T = unknown> {
51
+ data: AssistantHistory<T>[];
52
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,14 +1,16 @@
1
1
  import { Context as DefaultContext } from '../OAuth/Context';
2
+ import { FetchRequestInit } from 'expo/fetch';
3
+ import { FetchResponse } from 'expo/build/winter/fetch/FetchResponse';
2
4
  export type IMJson = {
3
5
  error?: boolean;
4
6
  errorMessage?: string;
5
7
  data?: Record<string, unknown>;
6
8
  };
7
- interface IMResponse<T> extends Response {
9
+ interface IMResponse<T> extends FetchResponse {
8
10
  json: () => Promise<T extends IMJson ? T & IMJson : undefined extends T ? IMJson : T>;
9
11
  }
10
12
  type UseIMFetch = (option?: {
11
13
  noValidate?: boolean;
12
- }, context?: typeof DefaultContext) => <T>(input: string, init?: RequestInit) => Promise<IMResponse<T>>;
14
+ }, context?: typeof DefaultContext) => <T>(input: string, init?: FetchRequestInit) => Promise<IMResponse<T>>;
13
15
  export declare const useIMFetch: UseIMFetch;
14
16
  export {};
@@ -4,6 +4,7 @@ import { join } from '../../utils/path';
4
4
  import { Context as DefaultContext } from '../OAuth/Context';
5
5
  import { IMOAuthError } from '../OAuth/IMOAuthError';
6
6
  import { IMFecthError } from './IMFecthError';
7
+ import { fetch } from 'expo/fetch';
7
8
  const fetchWrapper = async (token, input, init = {}) => {
8
9
  const response = await fetch(input, {
9
10
  credentials: 'omit',
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ErrorResult, SuccessResult } from '.';
3
2
  import { RenderTarget } from '../../_shared/renderTarget';
4
3
  import { Me } from './type';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { RenderTarget } from '../../_shared/renderTarget';
3
2
  import { Context as DefaultContext } from './Context';
4
3
  import { Me } from './type';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { RenderTarget } from '../../_shared/renderTarget';
3
2
  import { AuthSessionResult } from 'expo-auth-session';
4
3
  import { IMOAuthError } from './IMOAuthError';
@@ -3,4 +3,4 @@ export * from './useIMToken';
3
3
  export * from './useStartAuth';
4
4
  export * from './useAuthState';
5
5
  export * from './useAuthStateEffect';
6
- export * from './useAuthError';
6
+ export * from './useAuthInitError';
@@ -3,4 +3,4 @@ export * from './useIMToken';
3
3
  export * from './useStartAuth';
4
4
  export * from './useAuthState';
5
5
  export * from './useAuthStateEffect';
6
- export * from './useAuthError';
6
+ export * from './useAuthInitError';
@@ -0,0 +1,3 @@
1
+ import { DependencyList } from 'react';
2
+ import { IMOAuthError } from '../IMOAuthError';
3
+ export declare const useAuthInitError: (callBack: (error?: IMOAuthError) => void, deps?: DependencyList) => void;
@@ -0,0 +1,24 @@
1
+ import { useContext, useEffect, useRef } from 'react';
2
+ import { Context as DefaultContext } from '../Context';
3
+ import { IMOAuthError } from '../IMOAuthError';
4
+ export const useAuthInitError = (callBack, deps) => {
5
+ const initRef = useRef(true);
6
+ const firstEffectRef = useRef(true);
7
+ const oauthContext = useContext(DefaultContext);
8
+ if (oauthContext == null) {
9
+ throw new IMOAuthError('useAuthInitError requires either a Context provide or an ancestor element with a IMOAuthProvider.');
10
+ }
11
+ if (initRef.current) {
12
+ initRef.current = false;
13
+ oauthContext.authErrorRenderTarget.addEventListener(callBack);
14
+ }
15
+ useEffect(() => {
16
+ if (firstEffectRef.current)
17
+ firstEffectRef.current = false;
18
+ else
19
+ oauthContext.authErrorRenderTarget.addEventListener(callBack);
20
+ return () => {
21
+ oauthContext.authErrorRenderTarget.removeEventListener(callBack);
22
+ };
23
+ }, deps);
24
+ };
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Prompt } from 'expo-auth-session';
3
2
  import * as SecureStore from 'expo-secure-store';
4
3
  import { Context as DefaultContext } from './Context';
@@ -10,7 +10,7 @@ import { IMOAuthError } from './IMOAuthError';
10
10
  WebBrowser.maybeCompleteAuthSession();
11
11
  const SUCCESS = 'success';
12
12
  const EXCEPTION = 'exception';
13
- const DEFAULT_STORAGE_KEY = '_example_IMAuthKey';
13
+ const DEFAULT_STORE_KEY = '_example_IMAuthKey';
14
14
  const DEFAULT_REMAINING_TIME_TO_RUN_REFRESH = 360000;
15
15
  export const IMPrompt = {
16
16
  Login: Prompt.Login,
@@ -56,7 +56,7 @@ const useStoreConfig = (secureStore) => {
56
56
  const keychainAccessible = secureStore?.keychainAccessible;
57
57
  return useMemo(() => {
58
58
  return {
59
- storeKey: storeKey ? storeKey : DEFAULT_STORAGE_KEY,
59
+ storeKey: storeKey ? storeKey : DEFAULT_STORE_KEY,
60
60
  keychainAccessible: keychainAccessible !== void 0
61
61
  ? keychainAccessible
62
62
  : SecureStore.WHEN_UNLOCKED,
@@ -70,7 +70,7 @@ const useRemainingTimeToRunRefresh = (remainingTimeToRunRefresh) => {
70
70
  : DEFAULT_REMAINING_TIME_TO_RUN_REFRESH;
71
71
  }, [remainingTimeToRunRefresh]);
72
72
  };
73
- const saveTokenStorage = async (storeConfig, baseUrl, accessToken, refreshToken, expirationDate) => {
73
+ const saveTokenStore = async (storeConfig, baseUrl, accessToken, refreshToken, expirationDate) => {
74
74
  const item = {
75
75
  baseUrl,
76
76
  accessToken,
@@ -81,12 +81,12 @@ const saveTokenStorage = async (storeConfig, baseUrl, accessToken, refreshToken,
81
81
  keychainAccessible: storeConfig.keychainAccessible,
82
82
  });
83
83
  };
84
- const deleteTokenStorage = async (storeConfig) => {
84
+ const deleteTokenStore = async (storeConfig) => {
85
85
  return await SecureStore.deleteItemAsync(storeConfig.storeKey, {
86
86
  keychainAccessible: storeConfig.keychainAccessible,
87
87
  });
88
88
  };
89
- const getTokenStorage = async (storeConfig) => {
89
+ const getTokenStore = async (storeConfig) => {
90
90
  const state = await SecureStore.getItemAsync(storeConfig.storeKey, {
91
91
  keychainAccessible: storeConfig.keychainAccessible,
92
92
  });
@@ -176,7 +176,7 @@ const useRefresh = (storeConfig, refreshTokenRef, expirationDateRef, requestConf
176
176
  }, discovery);
177
177
  const { accessToken, refreshToken, expiresIn } = tokenResponse;
178
178
  const expirationDate = expiresIn ? createExpirationDate(expiresIn) : 0;
179
- await saveTokenStorage(storeConfig, baseUrl, accessToken, refreshToken, expirationDate);
179
+ await saveTokenStore(storeConfig, baseUrl, accessToken, refreshToken, expirationDate);
180
180
  refreshTokenRef.current = refreshToken ? refreshToken : null;
181
181
  expirationDateRef.current = expirationDate;
182
182
  setToken(accessToken);
@@ -198,7 +198,7 @@ const useStartAuth = (storeConfig, remainingTimeToRunRefresh, refreshTokenRef, e
198
198
  useEffect(() => {
199
199
  (async () => {
200
200
  try {
201
- const tokenState = await getTokenStorage(storeConfig);
201
+ const tokenState = await getTokenStore(storeConfig);
202
202
  if (tokenState) {
203
203
  const { baseUrl, accessToken, refreshToken, expirationDate } = tokenState;
204
204
  const expired = checkExpirationDateOfToken(expirationDate ? expirationDate : 0, remainingTimeToRunRefresh);
@@ -262,7 +262,7 @@ const useStartAuth = (storeConfig, remainingTimeToRunRefresh, refreshTokenRef, e
262
262
  }, discovery);
263
263
  const { accessToken, refreshToken, expiresIn } = tokenResponse;
264
264
  const expirationDate = expiresIn ? createExpirationDate(expiresIn) : 0;
265
- await saveTokenStorage(storeConfig, currentBaseUrl, accessToken, refreshToken, expirationDate);
265
+ await saveTokenStore(storeConfig, currentBaseUrl, accessToken, refreshToken, expirationDate);
266
266
  refreshTokenRef.current = refreshToken ? refreshToken : null;
267
267
  expirationDateRef.current = expirationDate;
268
268
  setToken(accessToken);
@@ -284,7 +284,7 @@ const useStartAuth = (storeConfig, remainingTimeToRunRefresh, refreshTokenRef, e
284
284
  };
285
285
  const useDestroy = (storeConfig, refreshTokenRef, expirationDateRef, setToken, setAuthState) => {
286
286
  return useCallback(async () => {
287
- await deleteTokenStorage(storeConfig);
287
+ await deleteTokenStore(storeConfig);
288
288
  setToken(null);
289
289
  refreshTokenRef.current = null;
290
290
  expirationDateRef.current = null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { StartSearchArg, StartSearchResult } from '.';
3
2
  export interface SearchContext {
4
3
  start: ({ target, type, paramString, }: StartSearchArg) => Promise<StartSearchResult<typeof type>>;
@@ -1,2 +1,3 @@
1
1
  import { DepartmentPostDepartmentSet, DepartmentPostSearchResult } from '../types';
2
- export declare const useDepartmentPostSearch: (paramString: string) => (departmentSet: DepartmentPostDepartmentSet, init?: RequestInit) => Promise<DepartmentPostSearchResult>;
2
+ import { FetchRequestInit } from 'expo/fetch';
3
+ export declare const useDepartmentPostSearch: (paramString: string) => (departmentSet: DepartmentPostDepartmentSet, init?: FetchRequestInit) => Promise<DepartmentPostSearchResult>;
@@ -1,2 +1,3 @@
1
1
  import { DepartmentSearcResult } from '../types';
2
- export declare const useDepartmentSearch: (paramString: string) => (keyword: string, init?: RequestInit) => Promise<DepartmentSearcResult>;
2
+ import { FetchRequestInit } from 'expo/fetch';
3
+ export declare const useDepartmentSearch: (paramString: string) => (keyword: string, init?: FetchRequestInit) => Promise<DepartmentSearcResult>;
@@ -1,2 +1,3 @@
1
1
  import { DepartmentTopSearcResult } from '../types';
2
- export declare const useDepartmentTopSearch: (paramString: string) => (init?: RequestInit) => Promise<DepartmentTopSearcResult>;
2
+ import { FetchRequestInit } from 'expo/fetch';
3
+ export declare const useDepartmentTopSearch: (paramString: string) => (init?: FetchRequestInit) => Promise<DepartmentTopSearcResult>;
@@ -1,4 +1,4 @@
1
1
  import { Context as DefaultContext } from '../Context';
2
2
  export declare const useIMSearch: (Context?: typeof DefaultContext) => {
3
- startSearch: ({ target, type, paramString, }: import("..").StartSearchArg) => Promise<import("..").StartSearchResult<import("..").SearchType>>;
3
+ startSearch: ({ target, type, paramString, }: import("..").StartSearchArg) => Promise<import("..").StartSearchResult<typeof type>>;
4
4
  };
@@ -1,2 +1,3 @@
1
1
  import { DepartmentSet, PostSearcResult } from '../types';
2
- export declare const usePostSearch: (paramString: string) => (departmentSet: DepartmentSet, init?: RequestInit) => Promise<PostSearcResult>;
2
+ import { FetchRequestInit } from 'expo/fetch';
3
+ export declare const usePostSearch: (paramString: string) => (departmentSet: DepartmentSet, init?: FetchRequestInit) => Promise<PostSearcResult>;
@@ -1,2 +1,3 @@
1
1
  import { PublicGroupRoleSearchResult, PublicGroupRoleSet } from '../types';
2
- export declare const usePublicGroupRoleSearch: (paramString: string) => (publicGroupSet: PublicGroupRoleSet, init?: RequestInit) => Promise<PublicGroupRoleSearchResult>;
2
+ import { FetchRequestInit } from 'expo/fetch';
3
+ export declare const usePublicGroupRoleSearch: (paramString: string) => (publicGroupSet: PublicGroupRoleSet, init?: FetchRequestInit) => Promise<PublicGroupRoleSearchResult>;
@@ -1,2 +1,3 @@
1
1
  import { PublicGroupSearcResult } from '../types';
2
- export declare const usePublicGroupSearch: (paramString: string) => (keyword: string, init?: RequestInit) => Promise<PublicGroupSearcResult>;
2
+ import { FetchRequestInit } from 'expo/fetch';
3
+ export declare const usePublicGroupSearch: (paramString: string) => (keyword: string, init?: FetchRequestInit) => Promise<PublicGroupSearcResult>;
@@ -1,2 +1,3 @@
1
1
  import { PublicGroupTopSearchResult } from '../types';
2
- export declare const usePublicGroupTopSearch: (paramString: string) => (init?: RequestInit) => Promise<PublicGroupTopSearchResult>;
2
+ import { FetchRequestInit } from 'expo/fetch';
3
+ export declare const usePublicGroupTopSearch: (paramString: string) => (init?: FetchRequestInit) => Promise<PublicGroupTopSearchResult>;
@@ -1,2 +1,3 @@
1
1
  import { PublicGroupSet, RoleSearchResult } from '../types';
2
- export declare const useRoleSearch: (paramString: string) => (publicGroupSet: PublicGroupSet, init?: RequestInit) => Promise<RoleSearchResult>;
2
+ import { FetchRequestInit } from 'expo/fetch';
3
+ export declare const useRoleSearch: (paramString: string) => (publicGroupSet: PublicGroupSet, init?: FetchRequestInit) => Promise<RoleSearchResult>;
@@ -1,2 +1,3 @@
1
1
  import { UserAdditionalInformationSearchResult } from '../types';
2
- export declare const useUserAdditionalInformationSearch: (paramString: string) => (userCd: string, init?: RequestInit) => Promise<UserAdditionalInformationSearchResult>;
2
+ import { FetchRequestInit } from 'expo/fetch';
3
+ export declare const useUserAdditionalInformationSearch: (paramString: string) => (userCd: string, init?: FetchRequestInit) => Promise<UserAdditionalInformationSearchResult>;
@@ -1,2 +1,3 @@
1
1
  import { UserSearchResult } from '../types';
2
- export declare const useUserSearch: (paramString: string) => (keyword: string, init?: RequestInit) => Promise<UserSearchResult>;
2
+ import { FetchRequestInit } from 'expo/fetch';
3
+ export declare const useUserSearch: (paramString: string) => (keyword: string, init?: FetchRequestInit) => Promise<UserSearchResult>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Context as DefaultContext } from './Context';
3
2
  import { DepartmentPostSearchRecord, DepartmentSearchRecord, PostSearchRecord, PublicGroupSearchRecord, RoleSearchRecord, UserSearchRecord } from './types';
4
3
  export type SearchTarget = 'jp.co.intra_mart.master.search.user' | 'jp.co.intra_mart.master.search.company' | 'jp.co.intra_mart.master.search.company_post' | 'jp.co.intra_mart.master.search.department' | 'jp.co.intra_mart.master.search.public_group' | 'jp.co.intra_mart.master.search.private_group' | 'jp.co.intra_mart.master.search.public_group_role' | 'jp.co.intra_mart.master.search.role' | 'jp.co.intra_mart.master.search.attached_department_post' | 'jp.co.intra_mart.master.search.attached_public_group_role' | undefined;
@@ -1,3 +1,4 @@
1
+ import { FetchResponse } from 'expo/build/winter/fetch/FetchResponse';
1
2
  export interface SuccessResponse<T> {
2
3
  error: false;
3
4
  message: string;
@@ -10,7 +11,7 @@ export interface Success<T> {
10
11
  export interface Error {
11
12
  readonly type: 'error';
12
13
  readonly detail: unknown;
13
- readonly response: Response;
14
+ readonly response: FetchResponse;
14
15
  }
15
16
  export interface Exception {
16
17
  readonly type: 'exception';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ErrorResult, SuccessResult } from '.';
3
2
  import { RenderTarget } from '../../_shared/renderTarget';
4
3
  import setCookie from 'set-cookie-parser';
@@ -1,4 +1,3 @@
1
- /// <reference types="set-cookie-parser" />
2
1
  import { Context as DefaultContext } from '../Context';
3
2
  export declare const useSession: (Context?: typeof DefaultContext) => {
4
3
  getSession: () => {
@@ -1,4 +1,3 @@
1
- /// <reference types="set-cookie-parser" />
2
1
  import { Context as DefaultContext } from '../Context';
3
2
  export declare const useSessionState: (Context?: typeof DefaultContext) => {
4
3
  cookies: import("set-cookie-parser").Cookie[] | null;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Context as DefaultContext } from './Context';
3
2
  export interface SessionResponse {
4
3
  error: boolean;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import { SelectSearchProps } from '../Search';
3
2
  export declare const NotSearchPropError: ({ error }: SelectSearchProps) => import("react").JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IMMe } from '../Me';
3
2
  import { IMOAuth } from '../OAuth';
4
3
  import { IMSession } from '../Session';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { FetchModuleState, Moudles } from '.';
3
2
  import { RenderTarget } from '../../_shared/renderTarget';
4
3
  export interface TenantContext {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { Context as DefaultContext } from './Context';
3
2
  import { ModuleIds } from './modulesType';
4
3
  interface IMTenantProps {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import WebView, { WebViewMessageEvent } from 'react-native-webview';
3
2
  type ErrorCallBack = (error: unknown) => void;
4
3
  export declare const useHackSearchUI: (errorCallBack?: ErrorCallBack) => {
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
- export declare const mergeRef: <T>(...refs: (string | import("react").MutableRefObject<T> | ((instance: T | null) => void) | import("react").MutableRefObject<T | null> | ((instance: T | null) => void) | import("react").RefObject<T> | null)[]) => (instance: T | null) => void;
1
+ export declare const mergeRef: <T>(...refs: Array<React.MutableRefObject<T> | React.ForwardedRef<T> | React.LegacyRef<T> | React.ForwardedRef<T>>) => React.RefCallback<T>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@intra-mart/smartlime",
3
3
  "description": "expoで使用できるintra mart accelplatform SDK",
4
- "version": "2.0.0-dev.20241125",
4
+ "version": "2.0.0-rc.20241226",
5
5
  "keywords": [
6
6
  "intra-mart",
7
7
  "AccelPlatform",
@@ -42,46 +42,42 @@
42
42
  "type": "tsc --noEmit"
43
43
  },
44
44
  "peerDependencies": {
45
- "expo": "^51.0.31",
46
- "react": "18.2.0"
45
+ "expo": "^52.0.20",
46
+ "react": "18.3.1"
47
47
  },
48
48
  "dependencies": {
49
49
  "@react-native-async-storage/async-storage": "1.23.1",
50
- "expo-auth-session": "~5.5.2",
51
- "expo-crypto": "~13.0.2",
50
+ "expo-auth-session": "~6.0.1",
51
+ "expo-crypto": "~14.0.1",
52
52
  "expo-random": "~14.0.1",
53
- "expo-secure-store": "~13.0.2",
54
- "react-native-webview": "13.8.6",
55
- "set-cookie-parser": "^2.7.0"
53
+ "expo-secure-store": "~14.0.0",
54
+ "react-native-webview": "13.12.5",
55
+ "set-cookie-parser": "^2.7.1"
56
56
  },
57
57
  "devDependencies": {
58
- "@babel/core": "^7.25.2",
59
- "@babel/preset-env": "^7.25.4",
60
- "@types/jest": "^29.5.12",
58
+ "@babel/core": "^7.26.0",
59
+ "@babel/preset-env": "^7.26.0",
60
+ "@types/jest": "^29.5.14",
61
61
  "@types/react": "^18.2.79",
62
62
  "@types/react-test-renderer": "18.3.0",
63
63
  "@types/set-cookie-parser": "^2.4.10",
64
- "@typescript-eslint/eslint-plugin": "^8.3.0",
65
- "@typescript-eslint/parser": "^8.3.0",
66
- "eslint": "^8.57.0",
64
+ "@typescript-eslint/eslint-plugin": "^8.18.0",
65
+ "@typescript-eslint/parser": "^8.18.0",
66
+ "eslint": "^9.16.0",
67
67
  "eslint-config-prettier": "^9.1.0",
68
- "eslint-plugin-react": "^7.35.0",
69
- "expo": "^51.0.31",
68
+ "eslint-plugin-react": "^7.37.2",
69
+ "expo": "~52.0.20",
70
70
  "jest": "^29.7.0",
71
- "jest-expo": "^51.0.4",
72
- "prettier": "^3.3.3",
73
- "react": "18.2.0",
74
- "react-dom": "18.2.0",
75
- "react-native": "0.74.5",
71
+ "jest-expo": "^52.0.2",
72
+ "prettier": "^3.4.2",
73
+ "react": "18.3.1",
74
+ "react-dom": "18.3.1",
75
+ "react-native": "0.76.5",
76
76
  "react-test-renderer": "18.2.0",
77
77
  "ts-jest": "^29.2.5",
78
- "typescript": "^5.3.3"
78
+ "typescript": "^5.7.2"
79
79
  },
80
- "resolutions": {
81
- "@types/react": "^18.2.79"
82
- },
83
- "packageManager": "yarn@1.22.19",
84
80
  "engines": {
85
- "node": ">= 16.9.0"
81
+ "node": ">= 22.0.0"
86
82
  }
87
83
  }
@@ -1,2 +0,0 @@
1
- import { IMOAuthError } from '../IMOAuthError';
2
- export declare const useAuthError: (callBack: (error?: IMOAuthError) => void) => void;
@@ -1,15 +0,0 @@
1
- import { useContext, useEffect } from 'react';
2
- import { Context as DefaultContext } from '../Context';
3
- import { IMOAuthError } from '../IMOAuthError';
4
- export const useAuthError = (callBack) => {
5
- const oauthContext = useContext(DefaultContext);
6
- if (oauthContext == null) {
7
- throw new IMOAuthError('useAuthError requires either a Context provide or an ancestor element with a IMOAuthProvider.');
8
- }
9
- useEffect(() => {
10
- oauthContext.authErrorRenderTarget.addEventListener(callBack);
11
- return () => {
12
- oauthContext.authErrorRenderTarget.removeEventListener(callBack);
13
- };
14
- }, [callBack]);
15
- };