mirror of
https://github.com/langgenius/dify.git
synced 2026-01-14 06:07:33 +08:00
Feat/update notion preview (#29345)
Co-authored-by: twwu <twwu@dify.ai>
This commit is contained in:
parent
d2b63df7a1
commit
ae4a9040df
@ -218,14 +218,14 @@ class DataSourceNotionListApi(Resource):
|
|||||||
|
|
||||||
|
|
||||||
@console_ns.route(
|
@console_ns.route(
|
||||||
"/notion/workspaces/<uuid:workspace_id>/pages/<uuid:page_id>/<string:page_type>/preview",
|
"/notion/pages/<uuid:page_id>/<string:page_type>/preview",
|
||||||
"/datasets/notion-indexing-estimate",
|
"/datasets/notion-indexing-estimate",
|
||||||
)
|
)
|
||||||
class DataSourceNotionApi(Resource):
|
class DataSourceNotionApi(Resource):
|
||||||
@setup_required
|
@setup_required
|
||||||
@login_required
|
@login_required
|
||||||
@account_initialization_required
|
@account_initialization_required
|
||||||
def get(self, workspace_id, page_id, page_type):
|
def get(self, page_id, page_type):
|
||||||
_, current_tenant_id = current_account_with_tenant()
|
_, current_tenant_id = current_account_with_tenant()
|
||||||
|
|
||||||
credential_id = request.args.get("credential_id", default=None, type=str)
|
credential_id = request.args.get("credential_id", default=None, type=str)
|
||||||
@ -239,11 +239,10 @@ class DataSourceNotionApi(Resource):
|
|||||||
plugin_id="langgenius/notion_datasource",
|
plugin_id="langgenius/notion_datasource",
|
||||||
)
|
)
|
||||||
|
|
||||||
workspace_id = str(workspace_id)
|
|
||||||
page_id = str(page_id)
|
page_id = str(page_id)
|
||||||
|
|
||||||
extractor = NotionExtractor(
|
extractor = NotionExtractor(
|
||||||
notion_workspace_id=workspace_id,
|
notion_workspace_id="",
|
||||||
notion_obj_id=page_id,
|
notion_obj_id=page_id,
|
||||||
notion_page_type=page_type,
|
notion_page_type=page_type,
|
||||||
notion_access_token=credential.get("integration_secret"),
|
notion_access_token=credential.get("integration_secret"),
|
||||||
|
|||||||
@ -10,7 +10,7 @@ class NotionInfo(BaseModel):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
credential_id: str | None = None
|
credential_id: str | None = None
|
||||||
notion_workspace_id: str
|
notion_workspace_id: str | None = ""
|
||||||
notion_obj_id: str
|
notion_obj_id: str
|
||||||
notion_page_type: str
|
notion_page_type: str
|
||||||
document: Document | None = None
|
document: Document | None = None
|
||||||
|
|||||||
@ -166,7 +166,7 @@ class ExtractProcessor:
|
|||||||
elif extract_setting.datasource_type == DatasourceType.NOTION:
|
elif extract_setting.datasource_type == DatasourceType.NOTION:
|
||||||
assert extract_setting.notion_info is not None, "notion_info is required"
|
assert extract_setting.notion_info is not None, "notion_info is required"
|
||||||
extractor = NotionExtractor(
|
extractor = NotionExtractor(
|
||||||
notion_workspace_id=extract_setting.notion_info.notion_workspace_id,
|
notion_workspace_id=extract_setting.notion_info.notion_workspace_id or "",
|
||||||
notion_obj_id=extract_setting.notion_info.notion_obj_id,
|
notion_obj_id=extract_setting.notion_info.notion_obj_id,
|
||||||
notion_page_type=extract_setting.notion_info.notion_page_type,
|
notion_page_type=extract_setting.notion_info.notion_page_type,
|
||||||
document_model=extract_setting.notion_info.document,
|
document_model=extract_setting.notion_info.document,
|
||||||
|
|||||||
@ -29,7 +29,6 @@ const NotionPagePreview = ({
|
|||||||
return
|
return
|
||||||
try {
|
try {
|
||||||
const res = await fetchNotionPagePreview({
|
const res = await fetchNotionPagePreview({
|
||||||
workspaceID: currentPage.workspace_id,
|
|
||||||
pageID: currentPage.page_id,
|
pageID: currentPage.page_id,
|
||||||
pageType: currentPage.type,
|
pageType: currentPage.type,
|
||||||
credentialID: notionCredentialId,
|
credentialID: notionCredentialId,
|
||||||
|
|||||||
@ -185,8 +185,8 @@ export const fetchFileIndexingEstimate = (body: IndexingEstimateParams): Promise
|
|||||||
return post<FileIndexingEstimateResponse>('/datasets/indexing-estimate', { body })
|
return post<FileIndexingEstimateResponse>('/datasets/indexing-estimate', { body })
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchNotionPagePreview = ({ workspaceID, pageID, pageType, credentialID }: { workspaceID: string; pageID: string; pageType: string; credentialID: string }): Promise<{ content: string }> => {
|
export const fetchNotionPagePreview = ({ pageID, pageType, credentialID }: { pageID: string; pageType: string; credentialID: string }): Promise<{ content: string }> => {
|
||||||
return get<{ content: string }>(`notion/workspaces/${workspaceID}/pages/${pageID}/${pageType}/preview`, {
|
return get<{ content: string }>(`notion/pages/${pageID}/${pageType}/preview`, {
|
||||||
params: {
|
params: {
|
||||||
credential_id: credentialID,
|
credential_id: credentialID,
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user