Skip to content

Commit f86b6cc

Browse files
types improvements
1 parent 7db965b commit f86b6cc

File tree

6 files changed

+36
-67
lines changed

6 files changed

+36
-67
lines changed

frontend/src/components/Popups/GraphEnhancementDialog/EnitityExtraction/EntityExtractionSetting.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Dropdown, Flex, Typography, useMediaQuery } from '@neo4j-ndl/react';
55
import { useCredentials } from '../../../../context/UserCredentials';
66
import { useFileContext } from '../../../../context/UsersFiles';
77
import { OnChangeValue, ActionMeta } from 'react-select';
8-
import { OptionType, OptionTypeForExamples, schema, UserCredentials } from '../../../../types';
8+
import { OptionType, schema, UserCredentials } from '../../../../types';
99
import { useAlertContext } from '../../../../context/Alert';
1010
import { getNodeLabelsAndRelTypes } from '../../../../services/GetNodeLabelsRelTypes';
1111
import schemaExamples from '../../../../assets/schemas.json';
@@ -154,8 +154,8 @@ export default function EntityExtractionSetting({
154154
const { showAlert } = useAlertContext();
155155

156156
useEffect(() => {
157-
const parsedData = schemaExamples.reduce((accu: OptionTypeForExamples[], example) => {
158-
const examplevalues: OptionTypeForExamples = {
157+
const parsedData = schemaExamples.reduce((accu: OptionType[], example) => {
158+
const examplevalues: OptionType = {
159159
label: example.schema,
160160
value: JSON.stringify({
161161
nodelabels: example.labels,

frontend/src/components/Popups/GraphEnhancementDialog/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import deleteOrphanAPI from '../../../services/DeleteOrphanNodes';
66
import { UserCredentials } from '../../../types';
77
import { useCredentials } from '../../../context/UserCredentials';
88
import EntityExtractionSettings from './EnitityExtraction/EntityExtractionSetting';
9-
import { AlertColor, AlertPropsColorOverrides } from '@mui/material';
10-
import { OverridableStringUnion } from '@mui/types';
119
import { useFileContext } from '../../../context/UsersFiles';
1210
import DeduplicationTab from './Deduplication';
1311
import { tokens } from '@neo4j-ndl/base';

frontend/src/components/Popups/Settings/SettingModal.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Dialog, Dropdown } from '@neo4j-ndl/react';
22
import { OnChangeValue, ActionMeta } from 'react-select';
3-
import { OptionType, OptionTypeForExamples, SettingsModalProps, UserCredentials, schema } from '../../../types';
3+
import { OptionType, SettingsModalProps, UserCredentials, schema } from '../../../types';
44
import { useFileContext } from '../../../context/UsersFiles';
55
import { getNodeLabelsAndRelTypes } from '../../../services/GetNodeLabelsRelTypes';
66
import { useCredentials } from '../../../context/UserCredentials';
@@ -129,8 +129,8 @@ const SettingsModal: React.FC<SettingsModalProps> = ({
129129
const { showAlert } = useAlertContext();
130130

131131
useEffect(() => {
132-
const parsedData = schemaExamples.reduce((accu: OptionTypeForExamples[], example) => {
133-
const examplevalues: OptionTypeForExamples = {
132+
const parsedData = schemaExamples.reduce((accu: OptionType[], example) => {
133+
const examplevalues: OptionType = {
134134
label: example.schema,
135135
value: JSON.stringify({
136136
nodelabels: example.labels,

frontend/src/hooks/useSourceInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useCallback, useState } from 'react';
2-
import { CustomFile, CustomFileBase, ScanProps, UserCredentials, fileName } from '../types';
2+
import { CustomFile, CustomFileBase, ScanProps, UserCredentials } from '../types';
33
import { useFileContext } from '../context/UsersFiles';
44
import { useCredentials } from '../context/UserCredentials';
55
import { urlScanAPI } from '../services/URLScan';

frontend/src/services/CommonAPI.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ const apiCall = async (
66
url: string,
77
method: Method,
88
commonParams: UserCredentials,
9-
additionalParams: FormDataParams
9+
additionalParams: Partial<FormDataParams>
1010
) => {
1111
try {
1212
const formData = new FormData();
1313
for (const key in commonParams) {
1414
formData.append(key, commonParams[key]);
1515
}
1616
for (const key in additionalParams) {
17+
if (additionalParams.hasOwnProperty(key)) {
1718
formData.append(key, additionalParams[key]);
19+
}
1820
}
1921
const response: AxiosResponse = await axios({
2022
method: method,

frontend/src/types.ts

Lines changed: 26 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,13 @@ export interface CustomFileBase extends Partial<globalThis.File> {
3030
}
3131
export interface CustomFile extends CustomFileBase {
3232
id: string;
33-
// total_pages: number | 'N/A';
3433
}
3534

3635
export interface OptionType {
3736
readonly value: string;
3837
readonly label: string;
3938
}
4039

41-
export interface OptionTypeForExamples {
42-
readonly value: string;
43-
readonly label: string;
44-
}
4540

4641
export type UserCredentials = {
4742
uri: string;
@@ -50,14 +45,27 @@ export type UserCredentials = {
5045
database: string;
5146
} & { [key: string]: any };
5247

53-
export type ExtractParams = {
48+
export interface SourceNode extends Omit<CustomFileBase,'relationshipCount'> {
49+
fileName: string;
50+
fileSize: number;
51+
fileType: string;
52+
nodeCount?: number;
53+
processingTime?: string;
54+
relationshipCount?: number;
55+
url?: string;
56+
awsAccessKeyId?: string;
57+
uploadprogress?: number;
58+
gcsProjectId?: string;
59+
processed_chunk?: number;
60+
total_chunks?: number;
61+
retry_condition?: string;
62+
}
63+
64+
export type ExtractParams = Pick<CustomFile,'wiki_query'|'model'|'source_url'|'language'|'access_token'>&{
5465
file?: File;
55-
model: string;
56-
source_url?: string;
5766
aws_access_key_id?: string | null;
5867
aws_secret_access_key?: string | null;
5968
max_sources?: number;
60-
wiki_query?: string;
6169
gcs_bucket_name?: string;
6270
gcs_bucket_folder?: string;
6371
gcs_blob_filename?: string;
@@ -66,10 +74,8 @@ export type ExtractParams = {
6674
allowedNodes?: string[];
6775
allowedRelationship?: string[];
6876
gcs_project_id?: string;
69-
language?: string;
70-
access_token?: string;
7177
retry_condition: string;
72-
} & { [key: string]: any };
78+
} & { [key: string]: any }
7379

7480
export type UploadParams = {
7581
file: Blob;
@@ -100,36 +106,11 @@ export interface S3ModalProps {
100106
hideModal: () => void;
101107
open: boolean;
102108
}
103-
export interface GCSModalProps {
104-
hideModal: () => void;
105-
open: boolean;
109+
export interface GCSModalProps extends Omit<S3ModalProps,''>{
106110
openGCSModal: () => void;
107111
}
108112

109-
export interface SourceNode {
110-
fileName: string;
111-
fileSize: number;
112-
fileType: string;
113-
nodeCount?: number;
114-
processingTime?: string;
115-
relationshipCount?: number;
116-
model: string;
117-
status: string;
118-
url?: string;
119-
awsAccessKeyId?: string;
120-
fileSource: string;
121-
gcsBucket?: string;
122-
gcsBucketFolder?: string;
123-
errorMessage?: string;
124-
uploadprogress?: number;
125-
gcsProjectId?: string;
126-
language?: string;
127-
processed_chunk?: number;
128-
total_chunks?: number;
129-
// total_pages?: number;
130-
access_token?: string;
131-
retry_condition?: string;
132-
}
113+
133114

134115
export interface SideNavProps {
135116
isExpanded: boolean;
@@ -254,9 +235,7 @@ export type ChatbotProps = {
254235
clear?: boolean;
255236
isFullScreen?: boolean;
256237
};
257-
export interface WikipediaModalTypes {
258-
hideModal: () => void;
259-
open: boolean;
238+
export interface WikipediaModalTypes extends Omit<S3ModalProps,''> {
260239
}
261240

262241
export interface GraphViewModalProps {
@@ -346,10 +325,8 @@ export type alertStateType = {
346325
alertType: OverridableStringUnion<AlertColor, AlertPropsColorOverrides> | undefined;
347326
alertMessage: string;
348327
};
349-
export interface BannerAlertProps {
350-
showAlert: boolean;
328+
export interface BannerAlertProps extends Omit<alertStateType,'alertType'>{
351329
alertType: BannerType;
352-
alertMessage: string;
353330
}
354331
export type Scheme = Record<string, string>;
355332

@@ -446,19 +423,11 @@ export interface chatInfoMessage extends Partial<Messages> {
446423
error: string;
447424
}
448425

449-
export interface eventResponsetypes {
450-
fileName: string;
451-
status: string;
452-
processingTime: number;
453-
nodeCount: number;
454-
relationshipCount: number;
455-
model: string;
426+
export interface eventResponsetypes extends Omit<SourceNode,'total_chunks'|'processingTime'> {
456427
total_chunks: number | null;
457-
// total_pages: number;
458-
fileSize: number;
459-
processed_chunk?: number;
460-
fileSource: string;
428+
processingTime:number
461429
}
430+
462431
export type Nullable<Type> = Type | null;
463432

464433
export type LabelColors = 'default' | 'success' | 'info' | 'warning' | 'danger' | undefined;
@@ -680,4 +649,4 @@ export interface ContextProps {
680649
export interface MessageContextType {
681650
messages: Messages[] | [];
682651
setMessages: Dispatch<SetStateAction<Messages[]>>;
683-
}
652+
}

0 commit comments

Comments
 (0)