code7-leia 0.2.2 → 0.2.4
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.
- package/dist/code7-leia.cjs.development.js +45 -36
- package/dist/code7-leia.cjs.development.js.map +1 -1
- package/dist/code7-leia.cjs.production.min.js +1 -1
- package/dist/code7-leia.cjs.production.min.js.map +1 -1
- package/dist/code7-leia.esm.js +45 -36
- package/dist/code7-leia.esm.js.map +1 -1
- package/dist/contexts/SharedPropsProvider.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/store/modules/actions.d.ts +10 -5
- package/package.json +1 -1
- package/src/components/FileArea/index.tsx +6 -7
- package/src/components/TestArea/index.tsx +3 -3
- package/src/contexts/SharedPropsProvider.tsx +2 -1
- package/src/index.tsx +1 -0
- package/src/store/modules/actions.ts +10 -10
- package/src/store/modules/sagas.ts +13 -13
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export declare const getFilesAction: (id: string) => {
|
|
1
|
+
export declare const getFilesAction: (id: string, token: string) => {
|
|
2
2
|
type: string;
|
|
3
3
|
payload: {
|
|
4
4
|
id: string;
|
|
5
|
+
token: string;
|
|
5
6
|
};
|
|
6
7
|
};
|
|
7
8
|
export declare const getFilesActionSuccess: ({ files }: any) => {
|
|
@@ -10,12 +11,13 @@ export declare const getFilesActionSuccess: ({ files }: any) => {
|
|
|
10
11
|
files: any;
|
|
11
12
|
};
|
|
12
13
|
};
|
|
13
|
-
export declare const deleteFilesAction: (name: string, id: string, language: string) => {
|
|
14
|
+
export declare const deleteFilesAction: (name: string, id: string, language: string, token: string) => {
|
|
14
15
|
type: string;
|
|
15
16
|
payload: {
|
|
16
17
|
name: string;
|
|
17
18
|
id: string;
|
|
18
19
|
language: string;
|
|
20
|
+
token: string;
|
|
19
21
|
};
|
|
20
22
|
};
|
|
21
23
|
export declare const deleteFilesActionSuccess: ({ files }: any) => {
|
|
@@ -24,13 +26,14 @@ export declare const deleteFilesActionSuccess: ({ files }: any) => {
|
|
|
24
26
|
files: any;
|
|
25
27
|
};
|
|
26
28
|
};
|
|
27
|
-
export declare const uploadFilesAction: (file: any, id: string, pressets: string[], language: string) => {
|
|
29
|
+
export declare const uploadFilesAction: (file: any, id: string, pressets: string[], language: string, token: string) => {
|
|
28
30
|
type: string;
|
|
29
31
|
payload: {
|
|
30
32
|
file: any;
|
|
31
33
|
id: string;
|
|
32
34
|
pressets: string[];
|
|
33
35
|
language: string;
|
|
36
|
+
token: string;
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
39
|
export declare const uploadFilesActionSuccess: ({ files }: any) => {
|
|
@@ -39,21 +42,23 @@ export declare const uploadFilesActionSuccess: ({ files }: any) => {
|
|
|
39
42
|
files: any;
|
|
40
43
|
};
|
|
41
44
|
};
|
|
42
|
-
export declare const trainingAction: (id: string, pressets: string[], language: string) => {
|
|
45
|
+
export declare const trainingAction: (id: string, pressets: string[], language: string, token: string) => {
|
|
43
46
|
type: string;
|
|
44
47
|
payload: {
|
|
45
48
|
id: string;
|
|
46
49
|
pressets: string[];
|
|
47
50
|
language: string;
|
|
51
|
+
token: string;
|
|
48
52
|
};
|
|
49
53
|
};
|
|
50
|
-
export declare const testAction: (question: string, profile: string, presset: string, files_directory: string) => {
|
|
54
|
+
export declare const testAction: (question: string, profile: string, presset: string, files_directory: string, token: string) => {
|
|
51
55
|
type: string;
|
|
52
56
|
payload: {
|
|
53
57
|
question: string;
|
|
54
58
|
profile: string;
|
|
55
59
|
presset: string;
|
|
56
60
|
files_directory: string;
|
|
61
|
+
token: string;
|
|
57
62
|
};
|
|
58
63
|
};
|
|
59
64
|
export declare const testActionSuccess: ({ message }: any) => {
|
package/package.json
CHANGED
|
@@ -23,7 +23,7 @@ import { SharedPropsProvider, useSharedProps } from '../../contexts/SharedPropsP
|
|
|
23
23
|
import { deleteFilesAction, getFilesAction, uploadFilesAction, trainingAction } from '../../store/modules/actions';
|
|
24
24
|
|
|
25
25
|
export const FileArea = () => {
|
|
26
|
-
const { id, language, propTags } = useSharedProps();
|
|
26
|
+
const { id, language, propTags, token } = useSharedProps();
|
|
27
27
|
const [files, setFiles] = useState<FileData[]>([]);
|
|
28
28
|
const [initialFiles, setInitialFiles] = useState<FileData[]>([]);
|
|
29
29
|
const [uploadFile, setUploadFile] = useState<{ content: ArrayBuffer | string; properties: File }>();
|
|
@@ -40,7 +40,7 @@ export const FileArea = () => {
|
|
|
40
40
|
const tags = propTags ? propTags.tags : [];
|
|
41
41
|
|
|
42
42
|
useEffect(() => {
|
|
43
|
-
dispatch(getFilesAction(id))
|
|
43
|
+
dispatch(getFilesAction(id, token))
|
|
44
44
|
}, [id])
|
|
45
45
|
|
|
46
46
|
useEffect(() => {
|
|
@@ -108,19 +108,19 @@ export const FileArea = () => {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const deleteFile = () => {
|
|
111
|
-
dispatch(deleteFilesAction(fileDelete, id, language))
|
|
111
|
+
dispatch(deleteFilesAction(fileDelete, id, language, token))
|
|
112
112
|
setModalDelete(false)
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
const handleUploadFile = () => {
|
|
116
|
-
dispatch(uploadFilesAction(uploadFile, id, presset, language))
|
|
116
|
+
dispatch(uploadFilesAction(uploadFile, id, presset, language, token))
|
|
117
117
|
setModal(false)
|
|
118
118
|
setUploadFile(undefined)
|
|
119
119
|
setPresset([])
|
|
120
120
|
};
|
|
121
121
|
|
|
122
122
|
const handleTrain = () => {
|
|
123
|
-
dispatch(trainingAction(id, presset, language))
|
|
123
|
+
dispatch(trainingAction(id, presset, language, token))
|
|
124
124
|
setModalTraining(false)
|
|
125
125
|
setPresset([])
|
|
126
126
|
};
|
|
@@ -156,7 +156,6 @@ export const FileArea = () => {
|
|
|
156
156
|
icon={<FaList></FaList>}
|
|
157
157
|
title={t.fileArea.emptyState.title}
|
|
158
158
|
description={t.fileArea.emptyState.description}
|
|
159
|
-
activeButton
|
|
160
159
|
iconButton={<button id='button-upload' onClick={handleOpenModal}><FaUpload size={14} /> {t.fileArea.fileUpload}</button>}
|
|
161
160
|
descriptionButton={t.fileArea.fileUpload}
|
|
162
161
|
widthButton="230px"
|
|
@@ -273,7 +272,7 @@ export const FileArea = () => {
|
|
|
273
272
|
}
|
|
274
273
|
|
|
275
274
|
return (
|
|
276
|
-
<SharedPropsProvider id={id} language={language} propTags={{ tags: [] }} personas={[{name: '', description: ''}]}>
|
|
275
|
+
<SharedPropsProvider id={id} language={language} token={token} propTags={{ tags: [] }} personas={[{name: '', description: ''}]}>
|
|
277
276
|
<S.Container>
|
|
278
277
|
{renderFiles()}
|
|
279
278
|
</S.Container>
|
|
@@ -12,7 +12,7 @@ import { useDispatch, useSelector } from 'react-redux';
|
|
|
12
12
|
import { testAction } from '../../store/modules/actions';
|
|
13
13
|
|
|
14
14
|
export const TestArea = () => {
|
|
15
|
-
const { id, language, personas, propTags } = useSharedProps();
|
|
15
|
+
const { id, language, personas, propTags, token } = useSharedProps();
|
|
16
16
|
const t = getLanguage(language)
|
|
17
17
|
const results = useSelector((state: any) => state.message);
|
|
18
18
|
const isloading = useSelector((state: any) => state.isloading);
|
|
@@ -44,7 +44,7 @@ export const TestArea = () => {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
const handleTest = () => {
|
|
47
|
-
dispatch(testAction(search, profile, presset, id))
|
|
47
|
+
dispatch(testAction(search, profile, presset, id, token))
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
const returnTest = () => {
|
|
@@ -83,7 +83,7 @@ export const TestArea = () => {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
return (
|
|
86
|
-
<SharedPropsProvider id={id} language={language} propTags={{ tags: [] }} personas={[{name: '', description: ''}]}>
|
|
86
|
+
<SharedPropsProvider id={id} token={token} language={language} propTags={{ tags: [] }} personas={[{name: '', description: ''}]}>
|
|
87
87
|
<S.Container>
|
|
88
88
|
{returnTest()}
|
|
89
89
|
</S.Container>
|
package/src/index.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import types from './types'
|
|
2
2
|
|
|
3
|
-
export const getFilesAction = (id: string) => {
|
|
3
|
+
export const getFilesAction = (id: string, token: string) => {
|
|
4
4
|
return {
|
|
5
5
|
type: types.GET_FILES_REQUEST,
|
|
6
|
-
payload: { id }
|
|
6
|
+
payload: { id, token }
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
@@ -14,10 +14,10 @@ export const getFilesActionSuccess = ({ files }: any) => {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export const deleteFilesAction = (name: string, id: string, language: string) => {
|
|
17
|
+
export const deleteFilesAction = (name: string, id: string, language: string, token: string) => {
|
|
18
18
|
return {
|
|
19
19
|
type: types.DELETE_FILES_REQUEST,
|
|
20
|
-
payload: { name, id, language }
|
|
20
|
+
payload: { name, id, language, token }
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -28,10 +28,10 @@ export const deleteFilesActionSuccess = ({ files }: any) => {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export const uploadFilesAction = (file: any, id: string, pressets: string[], language: string) => {
|
|
31
|
+
export const uploadFilesAction = (file: any, id: string, pressets: string[], language: string, token: string) => {
|
|
32
32
|
return {
|
|
33
33
|
type: types.UPLOAD_FILES_REQUEST,
|
|
34
|
-
payload: { file, id, pressets, language }
|
|
34
|
+
payload: { file, id, pressets, language, token }
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -42,17 +42,17 @@ export const uploadFilesActionSuccess = ({ files }: any) => {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export const trainingAction = (id: string, pressets: string[], language: string) => {
|
|
45
|
+
export const trainingAction = (id: string, pressets: string[], language: string, token: string) => {
|
|
46
46
|
return {
|
|
47
47
|
type: types.TRAINING_REQUEST,
|
|
48
|
-
payload: { id, pressets, language }
|
|
48
|
+
payload: { id, pressets, language, token }
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export const testAction = (question: string, profile: string, presset: string, files_directory: string) => {
|
|
52
|
+
export const testAction = (question: string, profile: string, presset: string, files_directory: string, token: string) => {
|
|
53
53
|
return {
|
|
54
54
|
type: types.TEST_REQUEST,
|
|
55
|
-
payload: { question, profile, presset, files_directory }
|
|
55
|
+
payload: { question, profile, presset, files_directory, token }
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -13,8 +13,8 @@ import { getLanguage } from '../../utils/getLanguage'
|
|
|
13
13
|
export function* getFilesSaga(action: any) {
|
|
14
14
|
try {
|
|
15
15
|
yield put(commonLoadingStart());
|
|
16
|
-
const { id } = action.payload
|
|
17
|
-
const { data } = yield call(api.get, `/training/${id}`);
|
|
16
|
+
const { id, token } = action.payload
|
|
17
|
+
const { data } = yield call(api.get, `/training/${id}?token=${token}`);
|
|
18
18
|
yield put(getFilesActionSuccess({ files: data.files}));
|
|
19
19
|
} catch (error) {
|
|
20
20
|
console.log('-----------getFiles.error------------------->', error);
|
|
@@ -27,10 +27,10 @@ export function* deleteFilesSaga(action: any) {
|
|
|
27
27
|
const t = getLanguage(action.payload.language)
|
|
28
28
|
try {
|
|
29
29
|
yield put(commonLoadingStart());
|
|
30
|
-
const { id, name } = action.payload
|
|
30
|
+
const { id, name, token } = action.payload
|
|
31
31
|
|
|
32
|
-
yield call(api.delete, `/delete/${id}/${name}`);
|
|
33
|
-
const { data } = yield call(api.get, `/training/${id}`);
|
|
32
|
+
yield call(api.delete, `/delete/${id}/${name}?token=${token}`);
|
|
33
|
+
const { data } = yield call(api.get, `/training/${id}?token=${token}`);
|
|
34
34
|
yield put(deleteFilesActionSuccess({ files: data.files, success: true }));
|
|
35
35
|
} catch (error) {
|
|
36
36
|
toast.error({title: t.toast.deleteFile.fail.title, description: t.toast.deleteFile.fail.description});
|
|
@@ -43,8 +43,8 @@ export function* deleteFilesSaga(action: any) {
|
|
|
43
43
|
export function* testSaga(action: any) {
|
|
44
44
|
try {
|
|
45
45
|
yield put(commonLoadingStart());
|
|
46
|
-
const { question, profile, presset, files_directory } = action.payload
|
|
47
|
-
const { data } = yield call(api.post, `/ask`, { question, profile, tag: presset, files_directory });
|
|
46
|
+
const { question, profile, presset, files_directory, token } = action.payload
|
|
47
|
+
const { data } = yield call(api.post, `/ask`, { question, profile, tag: presset, files_directory, token });
|
|
48
48
|
yield put(testActionSuccess({ message: data.message }));
|
|
49
49
|
} catch (error) {
|
|
50
50
|
console.log('-----------testSaga.error------------------->', error);
|
|
@@ -57,7 +57,7 @@ export function* uploadFilesSaga(action: any) {
|
|
|
57
57
|
const t = getLanguage(action.payload.language)
|
|
58
58
|
try {
|
|
59
59
|
yield put(commonLoadingStart());
|
|
60
|
-
const { id, file, pressets } = action.payload;
|
|
60
|
+
const { id, file, pressets, token } = action.payload;
|
|
61
61
|
const tags = pressets.join(',');
|
|
62
62
|
|
|
63
63
|
const blob = new Blob([file.content]);
|
|
@@ -67,13 +67,13 @@ export function* uploadFilesSaga(action: any) {
|
|
|
67
67
|
|
|
68
68
|
const queryParams = new URLSearchParams({ tags }).toString();
|
|
69
69
|
|
|
70
|
-
yield call(api.post, `/upload/${id}
|
|
70
|
+
yield call(api.post, `/upload/${id}?token=${token}&${queryParams}`, formData, {
|
|
71
71
|
headers: {
|
|
72
72
|
'Content-Type': 'multipart/form-data',
|
|
73
73
|
},
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
const { data } = yield call(api.get, `/training/${id}`);
|
|
76
|
+
const { data } = yield call(api.get, `/training/${id}?token=${token}`);
|
|
77
77
|
yield put(uploadFilesActionSuccess({ files: data.files }));
|
|
78
78
|
} catch (error) {
|
|
79
79
|
toast.error({title: t.toast.uploadFile.fail.title, description: t.toast.uploadFile.fail.description});
|
|
@@ -87,14 +87,14 @@ export function* TrainingSaga(action: any) {
|
|
|
87
87
|
const t = getLanguage(action.payload.language)
|
|
88
88
|
try {
|
|
89
89
|
yield put(commonLoadingStart());
|
|
90
|
-
const { id, pressets } = action.payload;
|
|
90
|
+
const { id, pressets, token } = action.payload;
|
|
91
91
|
const tag = pressets.join(',');
|
|
92
92
|
|
|
93
93
|
const queryParams = new URLSearchParams({ tag }).toString();
|
|
94
94
|
|
|
95
|
-
yield call(api.post, pressets.length > 0 ? `/training
|
|
95
|
+
yield call(api.post, pressets.length > 0 ? `/training?token=${token}&${queryParams}` : `/training?token=${token}`,{ files_directory: id });
|
|
96
96
|
|
|
97
|
-
const { data } = yield call(api.get, `/training/${id}`);
|
|
97
|
+
const { data } = yield call(api.get, `/training/${id}?token=${token}`);
|
|
98
98
|
yield put(uploadFilesActionSuccess({ files: data.files }));
|
|
99
99
|
toast.success({title: t.toast.Train.success.title, description: t.toast.Train.success.description});
|
|
100
100
|
} catch (error) {
|