feat: Enhance Notion integration by adding credential_id to NotionInfo and updating related functions

This commit is contained in:
twwu 2025-08-01 14:04:01 +08:00
parent 383ee368e6
commit 19a93c6554
4 changed files with 9 additions and 5 deletions

View File

@ -73,15 +73,15 @@ const NotionPageSelector = ({
const selectedPagesId = new Set<string>() const selectedPagesId = new Set<string>()
const boundPagesId = new Set<string>() const boundPagesId = new Set<string>()
const notionWorkspaces = notionsPages?.notion_info || [] const notionWorkspaces = notionsPages?.notion_info || []
const pagesMap = notionWorkspaces.reduce((prev: DataSourceNotionPageMap, next: DataSourceNotionWorkspace) => { const pagesMap = notionWorkspaces.reduce((prev: DataSourceNotionPageMap, cur: DataSourceNotionWorkspace) => {
next.pages.forEach((page) => { cur.pages.forEach((page) => {
if (page.is_bound) { if (page.is_bound) {
selectedPagesId.add(page.page_id) selectedPagesId.add(page.page_id)
boundPagesId.add(page.page_id) boundPagesId.add(page.page_id)
} }
prev[page.page_id] = { prev[page.page_id] = {
...page, ...page,
workspace_id: next.workspace_id, workspace_id: cur.workspace_id,
} }
}) })

View File

@ -472,7 +472,7 @@ const StepTwo = ({
} }
} }
if (dataSourceType === DataSourceType.NOTION) if (dataSourceType === DataSourceType.NOTION)
params.data_source.info_list.notion_info_list = getNotionInfo(notionPages) params.data_source.info_list.notion_info_list = getNotionInfo(notionPages, notionCredentialId)
if (dataSourceType === DataSourceType.WEB) { if (dataSourceType === DataSourceType.WEB) {
params.data_source.info_list.website_info_list = getWebsiteInfo({ params.data_source.info_list.website_info_list = getWebsiteInfo({

View File

@ -410,6 +410,7 @@ export type DataSource = {
export type NotionInfo = { export type NotionInfo = {
workspace_id: string workspace_id: string
pages: DataSourceNotionPage[] pages: DataSourceNotionPage[]
credential_id: string
} }
export type NotionPage = { export type NotionPage = {
page_id: string page_id: string

View File

@ -26,6 +26,7 @@ const NAME_SPACE = 'knowledge/create-dataset'
export const getNotionInfo = ( export const getNotionInfo = (
notionPages: NotionPage[], notionPages: NotionPage[],
credentialId: string,
) => { ) => {
const workspacesMap = groupBy(notionPages, 'workspace_id') const workspacesMap = groupBy(notionPages, 'workspace_id')
const workspaces = Object.keys(workspacesMap).map((workspaceId) => { const workspaces = Object.keys(workspacesMap).map((workspaceId) => {
@ -36,6 +37,7 @@ export const getNotionInfo = (
}) })
return workspaces.map((workspace) => { return workspaces.map((workspace) => {
return { return {
credential_id: credentialId,
workspace_id: workspace.workspaceId, workspace_id: workspace.workspaceId,
pages: workspace.pages.map((page) => { pages: workspace.pages.map((page) => {
const { page_id, page_name, page_icon, type } = page const { page_id, page_name, page_icon, type } = page
@ -130,11 +132,12 @@ const getFileIndexingEstimateParamsForNotion = ({
indexingTechnique, indexingTechnique,
processRule, processRule,
dataset_id, dataset_id,
credential_id,
}: GetFileIndexingEstimateParamsOptionNotion): IndexingEstimateParams => { }: GetFileIndexingEstimateParamsOptionNotion): IndexingEstimateParams => {
return { return {
info_list: { info_list: {
data_source_type: dataSourceType, data_source_type: dataSourceType,
notion_info_list: getNotionInfo(notionPages), notion_info_list: getNotionInfo(notionPages, credential_id),
}, },
indexing_technique: indexingTechnique, indexing_technique: indexingTechnique,
process_rule: processRule, process_rule: processRule,