mirror of https://github.com/langgenius/dify.git
feat: Enhance Notion integration by adding credential_id to NotionInfo and updating related functions
This commit is contained in:
parent
383ee368e6
commit
19a93c6554
|
|
@ -73,15 +73,15 @@ const NotionPageSelector = ({
|
|||
const selectedPagesId = new Set<string>()
|
||||
const boundPagesId = new Set<string>()
|
||||
const notionWorkspaces = notionsPages?.notion_info || []
|
||||
const pagesMap = notionWorkspaces.reduce((prev: DataSourceNotionPageMap, next: DataSourceNotionWorkspace) => {
|
||||
next.pages.forEach((page) => {
|
||||
const pagesMap = notionWorkspaces.reduce((prev: DataSourceNotionPageMap, cur: DataSourceNotionWorkspace) => {
|
||||
cur.pages.forEach((page) => {
|
||||
if (page.is_bound) {
|
||||
selectedPagesId.add(page.page_id)
|
||||
boundPagesId.add(page.page_id)
|
||||
}
|
||||
prev[page.page_id] = {
|
||||
...page,
|
||||
workspace_id: next.workspace_id,
|
||||
workspace_id: cur.workspace_id,
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ const StepTwo = ({
|
|||
}
|
||||
}
|
||||
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) {
|
||||
params.data_source.info_list.website_info_list = getWebsiteInfo({
|
||||
|
|
|
|||
|
|
@ -410,6 +410,7 @@ export type DataSource = {
|
|||
export type NotionInfo = {
|
||||
workspace_id: string
|
||||
pages: DataSourceNotionPage[]
|
||||
credential_id: string
|
||||
}
|
||||
export type NotionPage = {
|
||||
page_id: string
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ const NAME_SPACE = 'knowledge/create-dataset'
|
|||
|
||||
export const getNotionInfo = (
|
||||
notionPages: NotionPage[],
|
||||
credentialId: string,
|
||||
) => {
|
||||
const workspacesMap = groupBy(notionPages, 'workspace_id')
|
||||
const workspaces = Object.keys(workspacesMap).map((workspaceId) => {
|
||||
|
|
@ -36,6 +37,7 @@ export const getNotionInfo = (
|
|||
})
|
||||
return workspaces.map((workspace) => {
|
||||
return {
|
||||
credential_id: credentialId,
|
||||
workspace_id: workspace.workspaceId,
|
||||
pages: workspace.pages.map((page) => {
|
||||
const { page_id, page_name, page_icon, type } = page
|
||||
|
|
@ -130,11 +132,12 @@ const getFileIndexingEstimateParamsForNotion = ({
|
|||
indexingTechnique,
|
||||
processRule,
|
||||
dataset_id,
|
||||
credential_id,
|
||||
}: GetFileIndexingEstimateParamsOptionNotion): IndexingEstimateParams => {
|
||||
return {
|
||||
info_list: {
|
||||
data_source_type: dataSourceType,
|
||||
notion_info_list: getNotionInfo(notionPages),
|
||||
notion_info_list: getNotionInfo(notionPages, credential_id),
|
||||
},
|
||||
indexing_technique: indexingTechnique,
|
||||
process_rule: processRule,
|
||||
|
|
|
|||
Loading…
Reference in New Issue