chore: perfect type definition (#1003)
This commit is contained in:
@@ -87,7 +87,7 @@ const EmbeddingProcess: FC<Props> = ({ datasetId, batchId, documents = [], index
|
||||
setIndexingStatusDetail(status.data)
|
||||
}
|
||||
|
||||
const [runId, setRunId, getRunId] = useGetState<any>(null)
|
||||
const [_, setRunId, getRunId] = useGetState<ReturnType<typeof setInterval>>()
|
||||
|
||||
const stopQueryStatus = () => {
|
||||
clearInterval(getRunId())
|
||||
@@ -136,10 +136,10 @@ const EmbeddingProcess: FC<Props> = ({ datasetId, batchId, documents = [], index
|
||||
}
|
||||
|
||||
const isEmbedding = useMemo(() => {
|
||||
return indexingStatusBatchDetail.some((indexingStatusDetail: { indexing_status: any }) => ['indexing', 'splitting', 'parsing', 'cleaning'].includes(indexingStatusDetail?.indexing_status || ''))
|
||||
return indexingStatusBatchDetail.some(indexingStatusDetail => ['indexing', 'splitting', 'parsing', 'cleaning'].includes(indexingStatusDetail?.indexing_status || ''))
|
||||
}, [indexingStatusBatchDetail])
|
||||
const isEmbeddingCompleted = useMemo(() => {
|
||||
return indexingStatusBatchDetail.every((indexingStatusDetail: { indexing_status: any }) => ['completed', 'error'].includes(indexingStatusDetail?.indexing_status || ''))
|
||||
return indexingStatusBatchDetail.every(indexingStatusDetail => ['completed', 'error'].includes(indexingStatusDetail?.indexing_status || ''))
|
||||
}, [indexingStatusBatchDetail])
|
||||
|
||||
const getSourceName = (id: string) => {
|
||||
@@ -159,10 +159,11 @@ const EmbeddingProcess: FC<Props> = ({ datasetId, batchId, documents = [], index
|
||||
const doc = documents.find(document => document.id === id)
|
||||
return doc?.data_source_type as DataSourceType
|
||||
}
|
||||
const getIcon = (id: string) => {
|
||||
const doc = documents.find(document => document.id === id) as any // TODO type fix
|
||||
|
||||
return doc.data_source_info.notion_page_icon
|
||||
const getIcon = (id: string) => {
|
||||
const doc = documents.find(document => document.id === id)
|
||||
|
||||
return doc?.data_source_info.notion_page_icon
|
||||
}
|
||||
const isSourceEmbedding = (detail: IndexingStatusResponse) => ['indexing', 'splitting', 'parsing', 'cleaning', 'waiting'].includes(detail.indexing_status || '')
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ type IFileUploaderProps = {
|
||||
titleClassName?: string
|
||||
prepareFileList: (files: FileItem[]) => void
|
||||
onFileUpdate: (fileItem: FileItem, progress: number, list: FileItem[]) => void
|
||||
onFileListUpdate?: (files: any) => void
|
||||
onFileListUpdate?: (files: FileItem[]) => void
|
||||
onPreview: (file: File) => void
|
||||
countLimit: number
|
||||
countUsed: number
|
||||
|
||||
@@ -11,13 +11,11 @@ import { DataSourceType } from '@/models/datasets'
|
||||
import type { DataSet, FileItem, createDocumentResponse } from '@/models/datasets'
|
||||
import { fetchDataSource } from '@/service/common'
|
||||
import { fetchDataDetail } from '@/service/datasets'
|
||||
import type { DataSourceNotionPage } from '@/models/common'
|
||||
import type { NotionPage } from '@/models/common'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
|
||||
import AccountSetting from '@/app/components/header/account-setting'
|
||||
|
||||
type Page = DataSourceNotionPage & { workspace_id: string }
|
||||
|
||||
type DatasetUpdateFormProps = {
|
||||
datasetId?: string
|
||||
}
|
||||
@@ -35,8 +33,8 @@ const DatasetUpdateForm = ({ datasetId }: DatasetUpdateFormProps) => {
|
||||
const [hasError, setHasError] = useState(false)
|
||||
const { embeddingsDefaultModel } = useProviderContext()
|
||||
|
||||
const [notionPages, setNotionPages] = useState<Page[]>([])
|
||||
const updateNotionPages = (value: Page[]) => {
|
||||
const [notionPages, setNotionPages] = useState<NotionPage[]>([])
|
||||
const updateNotionPages = (value: NotionPage[]) => {
|
||||
setNotionPages(value)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,12 @@ import { useTranslation } from 'react-i18next'
|
||||
import cn from 'classnames'
|
||||
import { XMarkIcon } from '@heroicons/react/20/solid'
|
||||
import s from './index.module.css'
|
||||
import type { DataSourceNotionPage } from '@/models/common'
|
||||
import type { NotionPage } from '@/models/common'
|
||||
import NotionIcon from '@/app/components/base/notion-icon'
|
||||
import { fetchNotionPagePreview } from '@/service/datasets'
|
||||
|
||||
type Page = DataSourceNotionPage & { workspace_id: string }
|
||||
type IProps = {
|
||||
currentPage?: Page
|
||||
currentPage?: NotionPage
|
||||
hidePreview: () => void
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import NotionPagePreview from '../notion-page-preview'
|
||||
import EmptyDatasetCreationModal from '../empty-dataset-creation-modal'
|
||||
import s from './index.module.css'
|
||||
import type { FileItem } from '@/models/datasets'
|
||||
import type { DataSourceNotionPage } from '@/models/common'
|
||||
import type { NotionPage } from '@/models/common'
|
||||
import { DataSourceType } from '@/models/datasets'
|
||||
import Button from '@/app/components/base/button'
|
||||
import { NotionPageSelector } from '@/app/components/base/notion-page-selector'
|
||||
@@ -25,14 +25,12 @@ type IStepOneProps = {
|
||||
files: FileItem[]
|
||||
updateFileList: (files: FileItem[]) => void
|
||||
updateFile: (fileItem: FileItem, progress: number, list: FileItem[]) => void
|
||||
notionPages?: any[]
|
||||
updateNotionPages: (value: any[]) => void
|
||||
notionPages?: NotionPage[]
|
||||
updateNotionPages: (value: NotionPage[]) => void
|
||||
onStepChange: () => void
|
||||
changeType: (type: DataSourceType) => void
|
||||
}
|
||||
|
||||
type Page = DataSourceNotionPage & { workspace_id: string }
|
||||
|
||||
type NotionConnectorProps = {
|
||||
onSetting: () => void
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import Loading from '@/app/components/base/loading'
|
||||
|
||||
import Toast from '@/app/components/base/toast'
|
||||
import { formatNumber } from '@/utils/format'
|
||||
import type { DataSourceNotionPage } from '@/models/common'
|
||||
import type { NotionPage } from '@/models/common'
|
||||
import { DataSourceType, DocForm } from '@/models/datasets'
|
||||
import NotionIcon from '@/app/components/base/notion-icon'
|
||||
import Switch from '@/app/components/base/switch'
|
||||
@@ -33,8 +33,6 @@ import { useDatasetDetailContext } from '@/context/dataset-detail'
|
||||
import I18n from '@/context/i18n'
|
||||
import { IS_CE_EDITION } from '@/config'
|
||||
|
||||
type Page = DataSourceNotionPage & { workspace_id: string }
|
||||
|
||||
type StepTwoProps = {
|
||||
isSetting?: boolean
|
||||
documentDetail?: FullDocumentDetail
|
||||
@@ -44,7 +42,7 @@ type StepTwoProps = {
|
||||
indexingType?: string
|
||||
dataSourceType: DataSourceType
|
||||
files: CustomFile[]
|
||||
notionPages?: Page[]
|
||||
notionPages?: NotionPage[]
|
||||
onStepChange?: (delta: number) => void
|
||||
updateIndexingTypeCache?: (type: string) => void
|
||||
updateResultCache?: (res: createDocumentResponse) => void
|
||||
@@ -110,16 +108,16 @@ const StepTwo = ({
|
||||
return segmentationType === SegmentType.AUTO ? automaticFileIndexingEstimate : customFileIndexingEstimate
|
||||
})()
|
||||
|
||||
const scrollHandle = (e: any) => {
|
||||
if (e.target.scrollTop > 0)
|
||||
const scrollHandle = (e: Event) => {
|
||||
if ((e.target as HTMLDivElement).scrollTop > 0)
|
||||
setScrolled(true)
|
||||
|
||||
else
|
||||
setScrolled(false)
|
||||
}
|
||||
|
||||
const previewScrollHandle = (e: any) => {
|
||||
if (e.target.scrollTop > 0)
|
||||
const previewScrollHandle = (e: Event) => {
|
||||
if ((e.target as HTMLDivElement).scrollTop > 0)
|
||||
setPreviewScrolled(true)
|
||||
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user