From 820debc475cf1fb0992f15ef2429fa502e9e496d Mon Sep 17 00:00:00 2001 From: "codegen-sh[bot]" <131295404+codegen-sh[bot]@users.noreply.github.com> Date: Thu, 24 Apr 2025 09:04:40 +0000 Subject: [PATCH] Remove unnecessary imports and simplify parseTitle usage --- plugins/notion/server/notion.ts | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/plugins/notion/server/notion.ts b/plugins/notion/server/notion.ts index 0907c51513..2499f6fbfd 100644 --- a/plugins/notion/server/notion.ts +++ b/plugins/notion/server/notion.ts @@ -9,13 +9,8 @@ import { import { BlockObjectResponse, DatabaseObjectResponse, - ListBlockChildrenResponse, PageObjectResponse, - PartialBlockObjectResponse, - PartialDatabaseObjectResponse, - PartialPageObjectResponse, RichTextItemResponse, - SearchResponse, } from "@notionhq/client/build/src/api-endpoints"; import { RateLimit } from "async-sema"; import emojiRegex from "emoji-regex"; @@ -123,7 +118,7 @@ export class NotionClient { pages.push({ type: item.object === "page" ? PageType.Page : PageType.Database, id: item.id, - name: this.parseTitle(item, item.object === "database"), + name: this.parseTitle(item, true), emoji: this.parseEmoji(item), }); } @@ -169,7 +164,6 @@ export class NotionClient { cursor = response.next_cursor ?? undefined; } - // Recursive fetch when direct children have their own children. await Promise.all( blocks.map(async (block) => { if ( @@ -274,15 +268,12 @@ export class NotionClient { return user.name; } - // bot belongs to a user, get the user's name. if (user.bot.owner.type === "user" && isFullUser(user.bot.owner.user)) { return user.bot.owner.user.name; } - // bot belongs to a workspace, fallback to bot's name. return user.name; } catch (error) { - // Handle the case where a user can't be found if ( error instanceof APIResponseError && error.code === APIErrorCode.ObjectNotFound @@ -307,7 +298,6 @@ export class NotionClient { const title = richTexts.map((richText) => richText.plain_text).join(""); - // Use the appropriate validation limit based on context const maxLength = isCollection ? CollectionValidation.maxNameLength : DocumentValidation.maxTitleLength; @@ -316,7 +306,6 @@ export class NotionClient { } private parseEmoji(item: PageObjectResponse | DatabaseObjectResponse) { - // Other icon types return a url to download from, which we don't support. return item.icon?.type === "emoji" ? item.icon.emoji : undefined; } }