From eb116177a10ab8da0cf985d5c179a69b713d339d Mon Sep 17 00:00:00 2001 From: Aubin <60398825+aubin-tchoi@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:30:55 +0100 Subject: [PATCH] [Types] remove `provider` from `ContentNode`, rename `BaseContentNode` to `ContentNode` (#9895) * remove provider from ContentNode and replace BaseContentNode with ContentNode * stop sending provider in content nodes in connectors --- .../connectors/confluence/lib/permissions.ts | 2 -- connectors/src/connectors/github/index.ts | 14 -------------- .../src/connectors/google_drive/index.ts | 8 -------- connectors/src/connectors/intercom/index.ts | 19 ++++++++++--------- .../intercom/lib/conversation_permissions.ts | 5 ----- .../intercom/lib/help_center_permissions.ts | 6 ------ .../connectors/intercom/lib/permissions.ts | 3 --- .../connectors/microsoft/lib/content_nodes.ts | 9 --------- connectors/src/connectors/notion/index.ts | 6 ------ connectors/src/connectors/slack/index.ts | 10 +++++----- .../connectors/snowflake/lib/content_nodes.ts | 3 --- connectors/src/connectors/webcrawler/index.ts | 10 ++++------ .../src/connectors/zendesk/lib/permissions.ts | 4 ---- connectors/src/resources/zendesk_resources.ts | 6 ------ .../components/ConnectorPermissionsModal.tsx | 4 ++-- front/components/ContentNodeTree.tsx | 10 +++++----- .../assistant_builder/SlackIntegration.tsx | 4 ++-- front/lib/content_nodes.ts | 8 ++++---- types/src/front/data_source_view.ts | 11 +++-------- types/src/front/lib/connectors_api.ts | 11 ++--------- 20 files changed, 37 insertions(+), 116 deletions(-) diff --git a/connectors/src/connectors/confluence/lib/permissions.ts b/connectors/src/connectors/confluence/lib/permissions.ts index b286026d12b4..4efe4b8a8c15 100644 --- a/connectors/src/connectors/confluence/lib/permissions.ts +++ b/connectors/src/connectors/confluence/lib/permissions.ts @@ -46,7 +46,6 @@ export function createContentNodeFromSpace( const spaceId = isConfluenceSpaceModel(space) ? space.spaceId : space.id; return { - provider: "confluence", internalId: makeSpaceInternalId(spaceId), parentInternalId: null, type: "folder", @@ -66,7 +65,6 @@ export function createContentNodeFromPage( isExpandable = false ): ContentNode { return { - provider: "confluence", internalId: makePageInternalId(page.pageId), parentInternalId: parent.type === "space" diff --git a/connectors/src/connectors/github/index.ts b/connectors/src/connectors/github/index.ts index 4ff148eace5a..ca4a9305e614 100644 --- a/connectors/src/connectors/github/index.ts +++ b/connectors/src/connectors/github/index.ts @@ -286,7 +286,6 @@ export class GithubConnectorManager extends BaseConnectorManager { nodes = nodes.concat( page.map((repo) => ({ - provider: c.type, internalId: getRepositoryInternalId(repo.id), parentInternalId: null, type: "folder", @@ -358,7 +357,6 @@ export class GithubConnectorManager extends BaseConnectorManager { if (latestIssue) { nodes.push({ - provider: c.type, internalId: getIssuesInternalId(repoId), parentInternalId, type: "database", @@ -373,7 +371,6 @@ export class GithubConnectorManager extends BaseConnectorManager { if (latestDiscussion) { nodes.push({ - provider: c.type, internalId: getDiscussionsInternalId(repoId), parentInternalId, type: "channel", @@ -388,7 +385,6 @@ export class GithubConnectorManager extends BaseConnectorManager { if (codeRepo) { nodes.push({ - provider: c.type, internalId: getCodeRootInternalId(repoId), parentInternalId, type: "folder", @@ -431,7 +427,6 @@ export class GithubConnectorManager extends BaseConnectorManager { directories.forEach((directory) => { nodes.push({ - provider: c.type, internalId: directory.internalId, parentInternalId, type: "folder", @@ -446,7 +441,6 @@ export class GithubConnectorManager extends BaseConnectorManager { files.forEach((file) => { nodes.push({ - provider: c.type, internalId: file.documentId, parentInternalId, type: "file", @@ -609,7 +603,6 @@ export class GithubConnectorManager extends BaseConnectorManager { return; } nodes.push({ - provider: c.type, internalId: getRepositoryInternalId(repoId), parentInternalId: null, type: "folder", @@ -629,7 +622,6 @@ export class GithubConnectorManager extends BaseConnectorManager { return; } nodes.push({ - provider: c.type, internalId: getIssuesInternalId(repoId), parentInternalId: getRepositoryInternalId(repoId), type: "database", @@ -647,7 +639,6 @@ export class GithubConnectorManager extends BaseConnectorManager { return; } nodes.push({ - provider: c.type, internalId: getDiscussionsInternalId(repoId), parentInternalId: getRepositoryInternalId(repoId), type: "channel", @@ -667,7 +658,6 @@ export class GithubConnectorManager extends BaseConnectorManager { return; } nodes.push({ - provider: c.type, internalId: getIssueInternalId(repoId, issueNumber), parentInternalId: getIssuesInternalId(repoId), type: "file", @@ -687,7 +677,6 @@ export class GithubConnectorManager extends BaseConnectorManager { return; } nodes.push({ - provider: c.type, internalId: getDiscussionInternalId(repoId, discussionNumber), parentInternalId: getDiscussionsInternalId(repoId), type: "file", @@ -703,7 +692,6 @@ export class GithubConnectorManager extends BaseConnectorManager { // Constructing Nodes for Code fullCodeInRepos.forEach((codeRepo) => { nodes.push({ - provider: c.type, internalId: getCodeRootInternalId(codeRepo.repoId), parentInternalId: getRepositoryInternalId(codeRepo.repoId), type: "folder", @@ -719,7 +707,6 @@ export class GithubConnectorManager extends BaseConnectorManager { // Constructing Nodes for Code Directories codeDirectories.forEach((directory) => { nodes.push({ - provider: c.type, internalId: directory.internalId, parentInternalId: directory.parentInternalId, type: "folder", @@ -735,7 +722,6 @@ export class GithubConnectorManager extends BaseConnectorManager { // Constructing Nodes for Code Files codeFiles.forEach((file) => { nodes.push({ - provider: c.type, internalId: file.documentId, parentInternalId: file.parentInternalId, type: "file", diff --git a/connectors/src/connectors/google_drive/index.ts b/connectors/src/connectors/google_drive/index.ts index ec2caf0b40a0..d4341b8905f3 100644 --- a/connectors/src/connectors/google_drive/index.ts +++ b/connectors/src/connectors/google_drive/index.ts @@ -320,7 +320,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager { const type = getPermissionViewType(f); return { - provider: c.type, internalId: getInternalId(f.driveFileId), parentInternalId: null, type, @@ -344,7 +343,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager { nodes = nodes.concat( sheets.map((s) => { return { - provider: c.type, internalId: getGoogleSheetContentNodeInternalId( s.driveFileId, s.driveSheetId @@ -389,7 +387,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager { ); } return { - provider: c.type, internalId: getInternalId(driveObject.id), parentInternalId: // note: if the parent is null, the drive object falls at top-level @@ -417,7 +414,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager { // Adding a fake "Shared with me" node, to allow the user to see their shared files // that are not living in a shared drive. nodes.push({ - provider: c.type, internalId: getInternalId(GOOGLE_DRIVE_SHARED_WITH_ME_VIRTUAL_ID), parentInternalId: null, type: "folder" as const, @@ -486,7 +482,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager { ); return { - provider: c.type, internalId: getInternalId(driveObject.id), parentInternalId: driveObject.parent && getInternalId(driveObject.parent), @@ -673,7 +668,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager { const sourceUrl = getSourceUrlForGoogleDriveFiles(f); return { - provider: "google_drive", internalId: getInternalId(f.driveFileId), parentInternalId: null, type, @@ -713,7 +707,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager { })(); const sheetNodes: ContentNode[] = sheets.map((s) => ({ - provider: "google_drive", internalId: getGoogleSheetContentNodeInternalId( s.driveFileId, s.driveSheetId @@ -974,7 +967,6 @@ async function getFoldersAsContentNodes({ } const sourceUrl = `https://drive.google.com/drive/folders/${f.folderId}`; return { - provider: "google_drive", internalId: getInternalId(f.folderId), parentInternalId: null, type: "folder", diff --git a/connectors/src/connectors/intercom/index.ts b/connectors/src/connectors/intercom/index.ts index 93ca8cbab6d5..6a61b6e7655b 100644 --- a/connectors/src/connectors/intercom/index.ts +++ b/connectors/src/connectors/intercom/index.ts @@ -1,5 +1,9 @@ -import type { ConnectorPermission, ContentNode, Result } from "@dust-tt/types"; -import type { ContentNodesViewType } from "@dust-tt/types"; +import type { + ConnectorPermission, + ContentNode, + ContentNodesViewType, + Result, +} from "@dust-tt/types"; import { Err, Ok } from "@dust-tt/types"; import { Op } from "sequelize"; @@ -39,8 +43,10 @@ import type { RetrievePermissionsErrorCode, UpdateConnectorErrorCode, } from "@connectors/connectors/interface"; -import { ConnectorManagerError } from "@connectors/connectors/interface"; -import { BaseConnectorManager } from "@connectors/connectors/interface"; +import { + BaseConnectorManager, + ConnectorManagerError, +} from "@connectors/connectors/interface"; import { dataSourceConfigFromConnector } from "@connectors/lib/api/data_source_config"; import { ExternalOAuthTokenError } from "@connectors/lib/error"; import { @@ -613,7 +619,6 @@ export class IntercomConnectorManager extends BaseConnectorManager { const nodes: ContentNode[] = []; for (const helpCenter of helpCenters) { nodes.push({ - provider: "intercom", internalId: getHelpCenterInternalId( this.connectorId, helpCenter.helpCenterId @@ -630,7 +635,6 @@ export class IntercomConnectorManager extends BaseConnectorManager { } for (const collection of collections) { nodes.push({ - provider: "intercom", internalId: getHelpCenterCollectionInternalId( this.connectorId, collection.collectionId @@ -652,7 +656,6 @@ export class IntercomConnectorManager extends BaseConnectorManager { } for (const article of articles) { nodes.push({ - provider: "intercom", internalId: getHelpCenterArticleInternalId( this.connectorId, article.articleId @@ -674,7 +677,6 @@ export class IntercomConnectorManager extends BaseConnectorManager { } if (isAllConversations) { nodes.push({ - provider: "intercom", internalId: getTeamsInternalId(this.connectorId), parentInternalId: null, type: "channel", @@ -691,7 +693,6 @@ export class IntercomConnectorManager extends BaseConnectorManager { } for (const team of teams) { nodes.push({ - provider: "intercom", internalId: getTeamInternalId(this.connectorId, team.teamId), parentInternalId: getTeamsInternalId(this.connectorId), type: "channel", diff --git a/connectors/src/connectors/intercom/lib/conversation_permissions.ts b/connectors/src/connectors/intercom/lib/conversation_permissions.ts index a9b771705235..8e985bf589da 100644 --- a/connectors/src/connectors/intercom/lib/conversation_permissions.ts +++ b/connectors/src/connectors/intercom/lib/conversation_permissions.ts @@ -134,7 +134,6 @@ export async function retrieveIntercomConversationsPermissions({ if (isReadPermissionsOnly) { if (isRootLevel && isAllConversationsSynced) { nodes.push({ - provider: "intercom", internalId: allTeamsInternalId, parentInternalId: null, type: "channel", @@ -148,7 +147,6 @@ export async function retrieveIntercomConversationsPermissions({ }); } else if (isRootLevel && hasTeamsWithReadPermission) { nodes.push({ - provider: "intercom", internalId: allTeamsInternalId, parentInternalId: null, type: "channel", @@ -165,7 +163,6 @@ export async function retrieveIntercomConversationsPermissions({ if (parentInternalId === allTeamsInternalId) { teamsWithReadPermission.forEach((team) => { nodes.push({ - provider: connector.type, internalId: getTeamInternalId(connectorId, team.teamId), parentInternalId: allTeamsInternalId, type: "folder", @@ -183,7 +180,6 @@ export async function retrieveIntercomConversationsPermissions({ const teams = await fetchIntercomTeams({ accessToken }); if (isRootLevel) { nodes.push({ - provider: "intercom", internalId: allTeamsInternalId, parentInternalId: null, type: "channel", @@ -202,7 +198,6 @@ export async function retrieveIntercomConversationsPermissions({ return teamFromDb.teamId === team.id; }); nodes.push({ - provider: connector.type, internalId: getTeamInternalId(connectorId, team.id), parentInternalId: allTeamsInternalId, type: "folder", diff --git a/connectors/src/connectors/intercom/lib/help_center_permissions.ts b/connectors/src/connectors/intercom/lib/help_center_permissions.ts index 4898c9f37ab5..e494f19cf92b 100644 --- a/connectors/src/connectors/intercom/lib/help_center_permissions.ts +++ b/connectors/src/connectors/intercom/lib/help_center_permissions.ts @@ -364,7 +364,6 @@ export async function retrieveIntercomHelpCentersPermissions({ }, }); nodes = helpCentersFromDb.map((helpCenter) => ({ - provider: connector.type, internalId: getHelpCenterInternalId( connectorId, helpCenter.helpCenterId @@ -381,7 +380,6 @@ export async function retrieveIntercomHelpCentersPermissions({ } else { const helpCenters = await fetchIntercomHelpCenters({ accessToken }); nodes = helpCenters.map((helpCenter) => ({ - provider: connector.type, internalId: getHelpCenterInternalId(connectorId, helpCenter.id), parentInternalId: null, type: "database", @@ -425,7 +423,6 @@ export async function retrieveIntercomHelpCentersPermissions({ }); if (isReadPermissionsOnly) { nodes = collectionsInDb.map((collection) => ({ - provider: connector.type, internalId: getHelpCenterCollectionInternalId( connectorId, collection.collectionId @@ -452,7 +449,6 @@ export async function retrieveIntercomHelpCentersPermissions({ (c) => c.collectionId === collection.id ); return { - provider: connector.type, internalId: getHelpCenterCollectionInternalId( connectorId, collection.id @@ -493,7 +489,6 @@ export async function retrieveIntercomHelpCentersPermissions({ }); const collectionNodes: ContentNode[] = collectionsInDb.map( (collection) => ({ - provider: connector.type, internalId: getHelpCenterCollectionInternalId( connectorId, collection.collectionId @@ -522,7 +517,6 @@ export async function retrieveIntercomHelpCentersPermissions({ }, }); const articleNodes: ContentNode[] = articlesInDb.map((article) => ({ - provider: connector.type, internalId: getHelpCenterArticleInternalId( connectorId, article.articleId diff --git a/connectors/src/connectors/intercom/lib/permissions.ts b/connectors/src/connectors/intercom/lib/permissions.ts index 30c27f54b6bd..961dd9fbf2a0 100644 --- a/connectors/src/connectors/intercom/lib/permissions.ts +++ b/connectors/src/connectors/intercom/lib/permissions.ts @@ -50,7 +50,6 @@ export async function retrieveSelectedNodes({ ); collectionsNodes.push({ - provider: connector.type, internalId: getHelpCenterCollectionInternalId( connectorId, collection.collectionId @@ -79,7 +78,6 @@ export async function retrieveSelectedNodes({ intercomWorkspace?.syncAllConversations === "scheduled_activate" ) { teamsNodes.push({ - provider: connector.type, internalId: getTeamsInternalId(connectorId), parentInternalId: null, type: "channel", @@ -100,7 +98,6 @@ export async function retrieveSelectedNodes({ }); teams.forEach((team) => { teamsNodes.push({ - provider: connector.type, internalId: getTeamInternalId(connectorId, team.teamId), parentInternalId: getTeamsInternalId(connectorId), type: "folder", diff --git a/connectors/src/connectors/microsoft/lib/content_nodes.ts b/connectors/src/connectors/microsoft/lib/content_nodes.ts index f65e83166eae..d71efb4db289 100644 --- a/connectors/src/connectors/microsoft/lib/content_nodes.ts +++ b/connectors/src/connectors/microsoft/lib/content_nodes.ts @@ -17,7 +17,6 @@ export function getRootNodes(): ContentNode[] { export function getSitesRootAsContentNode(): ContentNode { return { - provider: "microsoft", internalId: internalIdFromTypeAndPath({ itemAPIPath: "", nodeType: "sites-root", @@ -36,7 +35,6 @@ export function getSitesRootAsContentNode(): ContentNode { export function getTeamsRootAsContentNode(): ContentNode { return { - provider: "microsoft", internalId: internalIdFromTypeAndPath({ itemAPIPath: "", nodeType: "teams-root", @@ -54,7 +52,6 @@ export function getTeamsRootAsContentNode(): ContentNode { } export function getTeamAsContentNode(team: microsoftgraph.Team): ContentNode { return { - provider: "microsoft", internalId: internalIdFromTypeAndPath({ itemAPIPath: `/teams/${team.id}`, nodeType: "team", @@ -80,7 +77,6 @@ export function getSiteAsContentNode( throw new Error("Site id is required"); } return { - provider: "microsoft", internalId: internalIdFromTypeAndPath({ itemAPIPath: getSiteAPIPath(site), nodeType: "site", @@ -111,7 +107,6 @@ export function getChannelAsContentNode( } return { - provider: "microsoft", internalId: internalIdFromTypeAndPath({ itemAPIPath: `/teams/${parentInternalId}/channels/${channel.id}`, nodeType: "channel", @@ -136,7 +131,6 @@ export function getDriveAsContentNode( throw new Error("Drive id is required"); } return { - provider: "microsoft", internalId: getDriveInternalId(drive), parentInternalId, type: "folder", @@ -153,7 +147,6 @@ export function getFolderAsContentNode( parentInternalId: string ): ContentNode { return { - provider: "microsoft", internalId: getDriveItemInternalId(folder), parentInternalId, type: "folder", @@ -171,7 +164,6 @@ export function getFileAsContentNode( parentInternalId: string ): ContentNode { return { - provider: "microsoft", internalId: getDriveItemInternalId(file), parentInternalId, type: "file", @@ -207,7 +199,6 @@ export function getMicrosoftNodeAsContentNode( } return { - provider: "microsoft", internalId: node.internalId, parentInternalId: node.parentInternalId, type, diff --git a/connectors/src/connectors/notion/index.ts b/connectors/src/connectors/notion/index.ts index 63b285c753ea..741b41772564 100644 --- a/connectors/src/connectors/notion/index.ts +++ b/connectors/src/connectors/notion/index.ts @@ -454,7 +454,6 @@ export class NotionConnectorManager extends BaseConnectorManager { const expandable = Boolean(hasChildrenByPageId[page.notionPageId]); return { - provider: c.type, internalId: nodeIdFromNotionId(page.notionPageId), parentInternalId: !page.parentId || page.parentId === "workspace" @@ -478,7 +477,6 @@ export class NotionConnectorManager extends BaseConnectorManager { const getDbNodes = async (db: NotionDatabase): Promise => { return { - provider: c.type, internalId: nodeIdFromNotionId(db.notionDatabaseId), parentInternalId: !db.parentId || db.parentId === "workspace" @@ -503,7 +501,6 @@ export class NotionConnectorManager extends BaseConnectorManager { // We also need to return a "fake" top-level folder call "Orphaned" to include resources // we haven't been able to find a parent for. folderNodes.push({ - provider: c.type, // Orphaned resources in the database will have "unknown" as their parentId. internalId: nodeIdFromNotionId("unknown"), parentInternalId: null, @@ -552,7 +549,6 @@ export class NotionConnectorManager extends BaseConnectorManager { const hasChildrenByPageId = await hasChildren(pages, this.connectorId); const pageNodes: ContentNode[] = await Promise.all( pages.map(async (page) => ({ - provider: "notion", internalId: nodeIdFromNotionId(page.notionPageId), parentInternalId: !page.parentId || page.parentId === "workspace" @@ -569,7 +565,6 @@ export class NotionConnectorManager extends BaseConnectorManager { ); const dbNodes: ContentNode[] = dbs.map((db) => ({ - provider: "notion", internalId: nodeIdFromNotionId(db.notionDatabaseId), parentInternalId: !db.parentId || db.parentId === "workspace" @@ -590,7 +585,6 @@ export class NotionConnectorManager extends BaseConnectorManager { const orphanedCount = await getOrphanedCount(this.connectorId); if (orphanedCount > 0) { contentNodes.push({ - provider: "notion", // Orphaned resources in the database will have "unknown" as their parentId. internalId: nodeIdFromNotionId("unknown"), parentInternalId: null, diff --git a/connectors/src/connectors/slack/index.ts b/connectors/src/connectors/slack/index.ts index 86347d0d92ca..4f6dc5a6f28b 100644 --- a/connectors/src/connectors/slack/index.ts +++ b/connectors/src/connectors/slack/index.ts @@ -1,11 +1,11 @@ import type { ConnectorPermission, ContentNode, + ContentNodesViewType, ModelId, Result, SlackConfigurationType, } from "@dust-tt/types"; -import type { ContentNodesViewType } from "@dust-tt/types"; import { Err, isSlackAutoReadPatterns, @@ -20,8 +20,10 @@ import type { RetrievePermissionsErrorCode, UpdateConnectorErrorCode, } from "@connectors/connectors/interface"; -import { ConnectorManagerError } from "@connectors/connectors/interface"; -import { BaseConnectorManager } from "@connectors/connectors/interface"; +import { + BaseConnectorManager, + ConnectorManagerError, +} from "@connectors/connectors/interface"; import { getChannels } from "@connectors/connectors/slack//temporal/activities"; import { getBotEnabled } from "@connectors/connectors/slack/bot"; import { joinChannel } from "@connectors/connectors/slack/lib/channels"; @@ -397,7 +399,6 @@ export class SlackConnectorManager extends BaseConnectorManager ({ - provider: "slack", internalId: slackChannelInternalIdFromSlackChannelId(ch.slackChannelId), parentInternalId: null, type: "channel", @@ -620,7 +621,6 @@ export class SlackConnectorManager extends BaseConnectorManager ({ - provider: "slack", internalId: slackChannelInternalIdFromSlackChannelId(ch.slackChannelId), parentInternalId: null, type: "channel", diff --git a/connectors/src/connectors/snowflake/lib/content_nodes.ts b/connectors/src/connectors/snowflake/lib/content_nodes.ts index f94659e8c03d..919dcf0fceb7 100644 --- a/connectors/src/connectors/snowflake/lib/content_nodes.ts +++ b/connectors/src/connectors/snowflake/lib/content_nodes.ts @@ -34,7 +34,6 @@ export const getContentNodeFromInternalId = ( if (type === "database") { return { - provider: "snowflake", internalId: databaseName as string, parentInternalId: null, type: "folder", @@ -49,7 +48,6 @@ export const getContentNodeFromInternalId = ( } if (type === "schema") { return { - provider: "snowflake", internalId: `${databaseName}.${schemaName}`, parentInternalId: databaseName as string, type: "folder", @@ -64,7 +62,6 @@ export const getContentNodeFromInternalId = ( } if (type === "table") { return { - provider: "snowflake", internalId: `${databaseName}.${schemaName}.${tableName}`, parentInternalId: `${databaseName}.${schemaName}`, type: "database", diff --git a/connectors/src/connectors/webcrawler/index.ts b/connectors/src/connectors/webcrawler/index.ts index 99e06b576ef6..d5d492c4f9bb 100644 --- a/connectors/src/connectors/webcrawler/index.ts +++ b/connectors/src/connectors/webcrawler/index.ts @@ -19,8 +19,10 @@ import type { RetrievePermissionsErrorCode, UpdateConnectorErrorCode, } from "@connectors/connectors/interface"; -import { ConnectorManagerError } from "@connectors/connectors/interface"; -import { BaseConnectorManager } from "@connectors/connectors/interface"; +import { + BaseConnectorManager, + ConnectorManagerError, +} from "@connectors/connectors/interface"; import { getDisplayNameForFolder, getDisplayNameForPage, @@ -199,7 +201,6 @@ export class WebcrawlerConnectorManager extends BaseConnectorManager !excludedFoldersSet.has(f.url)) .map((folder): ContentNode => { return { - provider: "webcrawler", internalId: folder.internalId, parentInternalId: folder.parentUrl ? stableIdForUrl({ @@ -222,7 +223,6 @@ export class WebcrawlerConnectorManager extends BaseConnectorManager { nodes.push({ - provider: "webcrawler", internalId: folder.internalId, parentInternalId: folder.parentUrl, title: getDisplayNameForFolder(folder), @@ -288,7 +287,6 @@ export class WebcrawlerConnectorManager extends BaseConnectorManager { nodes.push({ - provider: "webcrawler", internalId: page.documentId, parentInternalId: page.parentUrl, title: getDisplayNameForPage(page), diff --git a/connectors/src/connectors/zendesk/lib/permissions.ts b/connectors/src/connectors/zendesk/lib/permissions.ts index 26385b08f72f..420c79b8a286 100644 --- a/connectors/src/connectors/zendesk/lib/permissions.ts +++ b/connectors/src/connectors/zendesk/lib/permissions.ts @@ -76,7 +76,6 @@ async function getRootLevelContentNodes( brandsInDatabase .find((b) => b.brandId === brand.id) ?.toContentNode(connectorId) ?? { - provider: "zendesk", internalId: getBrandInternalId({ connectorId, brandId: brand.id }), parentInternalId: null, type: "folder", @@ -134,7 +133,6 @@ async function getBrandChildren( const ticketsNode: ContentNode = brandInDb?.getTicketsContentNode( connector.id ) ?? { - provider: "zendesk", internalId: getTicketsInternalId({ connectorId: connector.id, brandId }), parentInternalId: parentInternalId, type: "folder", @@ -152,7 +150,6 @@ async function getBrandChildren( const helpCenterNode: ContentNode = brandInDb?.getHelpCenterContentNode( connector.id ) ?? { - provider: "zendesk", internalId: getHelpCenterInternalId({ connectorId: connector.id, brandId, @@ -213,7 +210,6 @@ async function getHelpCenterChildren( categoriesInDatabase .find((c) => c.categoryId === category.id) ?.toContentNode(connectorId) ?? { - provider: "zendesk", internalId: getCategoryInternalId({ connectorId, brandId, diff --git a/connectors/src/resources/zendesk_resources.ts b/connectors/src/resources/zendesk_resources.ts index de45cb15a23d..7cf52360f365 100644 --- a/connectors/src/resources/zendesk_resources.ts +++ b/connectors/src/resources/zendesk_resources.ts @@ -330,7 +330,6 @@ export class ZendeskBrandResource extends BaseResource { toContentNode(connectorId: number): ContentNode { const { brandId } = this; return { - provider: "zendesk", internalId: getBrandInternalId({ connectorId, brandId }), parentInternalId: null, type: "folder", @@ -353,7 +352,6 @@ export class ZendeskBrandResource extends BaseResource { ): ContentNode & { parentInternalId: string } { const { brandId } = this; return { - provider: "zendesk", internalId: getHelpCenterInternalId({ connectorId, brandId }), parentInternalId: getBrandInternalId({ connectorId, brandId }), type: "folder", @@ -375,7 +373,6 @@ export class ZendeskBrandResource extends BaseResource { ): ContentNode & { parentInternalId: string } { const { brandId } = this; return { - provider: "zendesk", internalId: getTicketsInternalId({ connectorId, brandId }), parentInternalId: getBrandInternalId({ connectorId, brandId }), type: "folder", @@ -641,7 +638,6 @@ export class ZendeskCategoryResource extends BaseResource { ): ContentNode { const { brandId, categoryId, permission } = this; return { - provider: "zendesk", internalId: getCategoryInternalId({ connectorId, brandId, categoryId }), parentInternalId: getHelpCenterInternalId({ connectorId, brandId }), type: "folder", @@ -727,7 +723,6 @@ export class ZendeskTicketResource extends BaseResource { toContentNode(connectorId: number): ContentNode { const { brandId, ticketId } = this; return { - provider: "zendesk", internalId: getTicketInternalId({ connectorId, brandId, ticketId }), parentInternalId: getTicketsInternalId({ connectorId, brandId }), type: "file", @@ -939,7 +934,6 @@ export class ZendeskArticleResource extends BaseResource { toContentNode(connectorId: number): ContentNode { const { brandId, categoryId, articleId } = this; return { - provider: "zendesk", internalId: getArticleInternalId({ connectorId, brandId, articleId }), parentInternalId: getCategoryInternalId({ connectorId, diff --git a/front/components/ConnectorPermissionsModal.tsx b/front/components/ConnectorPermissionsModal.tsx index e75e19edc248..7be2be126627 100644 --- a/front/components/ConnectorPermissionsModal.tsx +++ b/front/components/ConnectorPermissionsModal.tsx @@ -28,10 +28,10 @@ import { } from "@dust-tt/sparkle"; import type { APIError, - BaseContentNode, ConnectorPermission, ConnectorProvider, ConnectorType, + ContentNode, DataSourceType, LightWorkspaceType, UpdateConnectorRequestBody, @@ -946,7 +946,7 @@ export async function confirmPrivateNodesSync({ selectedNodes, confirm, }: { - selectedNodes: BaseContentNode[]; + selectedNodes: ContentNode[]; confirm: (n: ConfirmDataType) => Promise; }): Promise { // confirmation in case there are private nodes diff --git a/front/components/ContentNodeTree.tsx b/front/components/ContentNodeTree.tsx index 81b05bb24b2f..d41b07f481c2 100644 --- a/front/components/ContentNodeTree.tsx +++ b/front/components/ContentNodeTree.tsx @@ -8,7 +8,7 @@ import { Tooltip, Tree, } from "@dust-tt/sparkle"; -import type { APIError, BaseContentNode } from "@dust-tt/types"; +import type { APIError, ContentNode } from "@dust-tt/types"; import type { ReactNode } from "react"; import React, { useCallback, useContext, useState } from "react"; @@ -17,7 +17,7 @@ import { classNames, timeAgoFrom } from "@app/lib/utils"; const unselectedChildren = ( selection: Record, - node: BaseContentNode + node: ContentNode ) => Object.entries(selection).reduce((acc, [k, v]) => { const shouldUnselect = v.parents.includes(node.internalId); @@ -32,7 +32,7 @@ const unselectedChildren = ( }, {}); export type UseResourcesHook = (parentId: string | null) => { - resources: BaseContentNode[]; + resources: ContentNode[]; isResourcesLoading: boolean; isResourcesError: boolean; resourcesError?: APIError | null; @@ -40,7 +40,7 @@ export type UseResourcesHook = (parentId: string | null) => { export type ContentNodeTreeItemStatus = { isSelected: boolean; - node: BaseContentNode; + node: ContentNode; parents: string[]; }; @@ -121,7 +121,7 @@ function ContentNodeTreeChildren({ ); const getCheckedState = useCallback( - (node: BaseContentNode) => { + (node: ContentNode) => { if (!selectedNodes) { return false; } diff --git a/front/components/assistant_builder/SlackIntegration.tsx b/front/components/assistant_builder/SlackIntegration.tsx index 9bcfde333339..638809edbc7d 100644 --- a/front/components/assistant_builder/SlackIntegration.tsx +++ b/front/components/assistant_builder/SlackIntegration.tsx @@ -6,7 +6,7 @@ import { SlackLogo, } from "@dust-tt/sparkle"; import type { - BaseContentNode, + ContentNode, DataSourceType, WorkspaceType, } from "@dust-tt/types"; @@ -52,7 +52,7 @@ export function SlackIntegration({ }, [existingSelection, newSelection]); const customIsNodeChecked = useCallback( - (node: BaseContentNode) => { + (node: ContentNode) => { return ( newSelection?.some((c) => c.slackChannelId === node.internalId) || false ); diff --git a/front/lib/content_nodes.ts b/front/lib/content_nodes.ts index c33e4e29d1ff..68452c7b1ef1 100644 --- a/front/lib/content_nodes.ts +++ b/front/lib/content_nodes.ts @@ -6,10 +6,10 @@ import { LockIcon, Square3Stack3DIcon, } from "@dust-tt/sparkle"; -import type { BaseContentNode } from "@dust-tt/types"; +import type { ContentNode } from "@dust-tt/types"; import { assertNever } from "@dust-tt/types"; -function getVisualForFileContentNode(node: BaseContentNode & { type: "file" }) { +function getVisualForFileContentNode(node: ContentNode & { type: "file" }) { if (node.expandable) { return DocumentPileIcon; } @@ -17,7 +17,7 @@ function getVisualForFileContentNode(node: BaseContentNode & { type: "file" }) { return DocumentIcon; } -export function getVisualForContentNode(node: BaseContentNode) { +export function getVisualForContentNode(node: ContentNode) { switch (node.type) { case "channel": if (node.providerVisibility === "private") { @@ -30,7 +30,7 @@ export function getVisualForContentNode(node: BaseContentNode) { case "file": return getVisualForFileContentNode( - node as BaseContentNode & { type: "file" } + node as ContentNode & { type: "file" } ); case "folder": diff --git a/types/src/front/data_source_view.ts b/types/src/front/data_source_view.ts index 392d763b4d28..cf0f01c0cd44 100644 --- a/types/src/front/data_source_view.ts +++ b/types/src/front/data_source_view.ts @@ -1,12 +1,7 @@ import { ModelId } from "../shared/model_id"; import { DataSourceViewCategory } from "./api_handlers/public/spaces"; -import { - ConnectorStatusDetails, - DataSourceType, - DataSourceWithAgentsUsageType, - EditedByUser, -} from "./data_source"; -import { BaseContentNode } from "./lib/connectors_api"; +import { ConnectorStatusDetails, DataSourceType, DataSourceWithAgentsUsageType, EditedByUser } from "./data_source"; +import { ContentNode } from "./lib/connectors_api"; export interface DataSourceViewType { category: DataSourceViewCategory; @@ -26,7 +21,7 @@ export type DataSourceViewsWithDetails = DataSourceViewType & { usage: DataSourceWithAgentsUsageType; }; -export type DataSourceViewContentNode = BaseContentNode & { +export type DataSourceViewContentNode = ContentNode & { parentInternalIds: string[] | null; }; diff --git a/types/src/front/lib/connectors_api.ts b/types/src/front/lib/connectors_api.ts index d53ff73e0ff5..f31ee8d98ce7 100644 --- a/types/src/front/lib/connectors_api.ts +++ b/types/src/front/lib/connectors_api.ts @@ -1,7 +1,4 @@ -import { - AdminCommandType, - AdminResponseType, -} from "../../connectors/admin/cli"; +import { AdminCommandType, AdminResponseType } from "../../connectors/admin/cli"; import { ConnectorsAPIError, isConnectorsAPIError } from "../../connectors/api"; import { UpdateConnectorConfigurationType } from "../../connectors/api_handlers/connector_configuration"; import { ConnectorCreateRequestBody } from "../../connectors/api_handlers/create_connector"; @@ -96,7 +93,7 @@ export const contentNodeTypeSortOrder: Record = { * information. More details here: * https://www.notion.so/dust-tt/Design-Doc-Microsoft-ids-parents-c27726652aae45abafaac587b971a41d?pvs=4 */ -export interface BaseContentNode { +export interface ContentNode { internalId: string; // The direct parent ID of this content node parentInternalId: string | null; @@ -111,10 +108,6 @@ export interface BaseContentNode { providerVisibility?: "public" | "private"; } -export type ContentNode = BaseContentNode & { - provider: ConnectorProvider; -}; - export type ContentNodeWithParentIds = ContentNode & { // A list of all parent IDs up to the root node, including the direct parent // Note: When includeParents is true, this list will be populated