Skip to content

Commit

Permalink
[Types] remove provider from ContentNode, rename `BaseContentNode…
Browse files Browse the repository at this point in the history
…` to `ContentNode` (#9895)

* remove provider from ContentNode and replace BaseContentNode with ContentNode

* stop sending provider in content nodes in connectors
  • Loading branch information
aubin-tchoi authored Jan 13, 2025
1 parent 29b6223 commit eb11617
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 116 deletions.
2 changes: 0 additions & 2 deletions connectors/src/connectors/confluence/lib/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -66,7 +65,6 @@ export function createContentNodeFromPage(
isExpandable = false
): ContentNode {
return {
provider: "confluence",
internalId: makePageInternalId(page.pageId),
parentInternalId:
parent.type === "space"
Expand Down
14 changes: 0 additions & 14 deletions connectors/src/connectors/github/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {

nodes = nodes.concat(
page.map((repo) => ({
provider: c.type,
internalId: getRepositoryInternalId(repo.id),
parentInternalId: null,
type: "folder",
Expand Down Expand Up @@ -358,7 +357,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {

if (latestIssue) {
nodes.push({
provider: c.type,
internalId: getIssuesInternalId(repoId),
parentInternalId,
type: "database",
Expand All @@ -373,7 +371,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {

if (latestDiscussion) {
nodes.push({
provider: c.type,
internalId: getDiscussionsInternalId(repoId),
parentInternalId,
type: "channel",
Expand All @@ -388,7 +385,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {

if (codeRepo) {
nodes.push({
provider: c.type,
internalId: getCodeRootInternalId(repoId),
parentInternalId,
type: "folder",
Expand Down Expand Up @@ -431,7 +427,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {

directories.forEach((directory) => {
nodes.push({
provider: c.type,
internalId: directory.internalId,
parentInternalId,
type: "folder",
Expand All @@ -446,7 +441,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {

files.forEach((file) => {
nodes.push({
provider: c.type,
internalId: file.documentId,
parentInternalId,
type: "file",
Expand Down Expand Up @@ -609,7 +603,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {
return;
}
nodes.push({
provider: c.type,
internalId: getRepositoryInternalId(repoId),
parentInternalId: null,
type: "folder",
Expand All @@ -629,7 +622,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {
return;
}
nodes.push({
provider: c.type,
internalId: getIssuesInternalId(repoId),
parentInternalId: getRepositoryInternalId(repoId),
type: "database",
Expand All @@ -647,7 +639,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {
return;
}
nodes.push({
provider: c.type,
internalId: getDiscussionsInternalId(repoId),
parentInternalId: getRepositoryInternalId(repoId),
type: "channel",
Expand All @@ -667,7 +658,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {
return;
}
nodes.push({
provider: c.type,
internalId: getIssueInternalId(repoId, issueNumber),
parentInternalId: getIssuesInternalId(repoId),
type: "file",
Expand All @@ -687,7 +677,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {
return;
}
nodes.push({
provider: c.type,
internalId: getDiscussionInternalId(repoId, discussionNumber),
parentInternalId: getDiscussionsInternalId(repoId),
type: "file",
Expand All @@ -703,7 +692,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {
// Constructing Nodes for Code
fullCodeInRepos.forEach((codeRepo) => {
nodes.push({
provider: c.type,
internalId: getCodeRootInternalId(codeRepo.repoId),
parentInternalId: getRepositoryInternalId(codeRepo.repoId),
type: "folder",
Expand All @@ -719,7 +707,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {
// Constructing Nodes for Code Directories
codeDirectories.forEach((directory) => {
nodes.push({
provider: c.type,
internalId: directory.internalId,
parentInternalId: directory.parentInternalId,
type: "folder",
Expand All @@ -735,7 +722,6 @@ export class GithubConnectorManager extends BaseConnectorManager<null> {
// Constructing Nodes for Code Files
codeFiles.forEach((file) => {
nodes.push({
provider: c.type,
internalId: file.documentId,
parentInternalId: file.parentInternalId,
type: "file",
Expand Down
8 changes: 0 additions & 8 deletions connectors/src/connectors/google_drive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager<null> {
const type = getPermissionViewType(f);

return {
provider: c.type,
internalId: getInternalId(f.driveFileId),
parentInternalId: null,
type,
Expand All @@ -344,7 +343,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager<null> {
nodes = nodes.concat(
sheets.map((s) => {
return {
provider: c.type,
internalId: getGoogleSheetContentNodeInternalId(
s.driveFileId,
s.driveSheetId
Expand Down Expand Up @@ -389,7 +387,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager<null> {
);
}
return {
provider: c.type,
internalId: getInternalId(driveObject.id),
parentInternalId:
// note: if the parent is null, the drive object falls at top-level
Expand Down Expand Up @@ -417,7 +414,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager<null> {
// 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,
Expand Down Expand Up @@ -486,7 +482,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager<null> {
);

return {
provider: c.type,
internalId: getInternalId(driveObject.id),
parentInternalId:
driveObject.parent && getInternalId(driveObject.parent),
Expand Down Expand Up @@ -673,7 +668,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager<null> {
const sourceUrl = getSourceUrlForGoogleDriveFiles(f);

return {
provider: "google_drive",
internalId: getInternalId(f.driveFileId),
parentInternalId: null,
type,
Expand Down Expand Up @@ -713,7 +707,6 @@ export class GoogleDriveConnectorManager extends BaseConnectorManager<null> {
})();

const sheetNodes: ContentNode[] = sheets.map((s) => ({
provider: "google_drive",
internalId: getGoogleSheetContentNodeInternalId(
s.driveFileId,
s.driveSheetId
Expand Down Expand Up @@ -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",
Expand Down
19 changes: 10 additions & 9 deletions connectors/src/connectors/intercom/index.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -613,7 +619,6 @@ export class IntercomConnectorManager extends BaseConnectorManager<null> {
const nodes: ContentNode[] = [];
for (const helpCenter of helpCenters) {
nodes.push({
provider: "intercom",
internalId: getHelpCenterInternalId(
this.connectorId,
helpCenter.helpCenterId
Expand All @@ -630,7 +635,6 @@ export class IntercomConnectorManager extends BaseConnectorManager<null> {
}
for (const collection of collections) {
nodes.push({
provider: "intercom",
internalId: getHelpCenterCollectionInternalId(
this.connectorId,
collection.collectionId
Expand All @@ -652,7 +656,6 @@ export class IntercomConnectorManager extends BaseConnectorManager<null> {
}
for (const article of articles) {
nodes.push({
provider: "intercom",
internalId: getHelpCenterArticleInternalId(
this.connectorId,
article.articleId
Expand All @@ -674,7 +677,6 @@ export class IntercomConnectorManager extends BaseConnectorManager<null> {
}
if (isAllConversations) {
nodes.push({
provider: "intercom",
internalId: getTeamsInternalId(this.connectorId),
parentInternalId: null,
type: "channel",
Expand All @@ -691,7 +693,6 @@ export class IntercomConnectorManager extends BaseConnectorManager<null> {
}
for (const team of teams) {
nodes.push({
provider: "intercom",
internalId: getTeamInternalId(this.connectorId, team.teamId),
parentInternalId: getTeamsInternalId(this.connectorId),
type: "channel",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ export async function retrieveIntercomConversationsPermissions({
if (isReadPermissionsOnly) {
if (isRootLevel && isAllConversationsSynced) {
nodes.push({
provider: "intercom",
internalId: allTeamsInternalId,
parentInternalId: null,
type: "channel",
Expand All @@ -148,7 +147,6 @@ export async function retrieveIntercomConversationsPermissions({
});
} else if (isRootLevel && hasTeamsWithReadPermission) {
nodes.push({
provider: "intercom",
internalId: allTeamsInternalId,
parentInternalId: null,
type: "channel",
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ export async function retrieveIntercomHelpCentersPermissions({
},
});
nodes = helpCentersFromDb.map((helpCenter) => ({
provider: connector.type,
internalId: getHelpCenterInternalId(
connectorId,
helpCenter.helpCenterId
Expand All @@ -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",
Expand Down Expand Up @@ -425,7 +423,6 @@ export async function retrieveIntercomHelpCentersPermissions({
});
if (isReadPermissionsOnly) {
nodes = collectionsInDb.map((collection) => ({
provider: connector.type,
internalId: getHelpCenterCollectionInternalId(
connectorId,
collection.collectionId
Expand All @@ -452,7 +449,6 @@ export async function retrieveIntercomHelpCentersPermissions({
(c) => c.collectionId === collection.id
);
return {
provider: connector.type,
internalId: getHelpCenterCollectionInternalId(
connectorId,
collection.id
Expand Down Expand Up @@ -493,7 +489,6 @@ export async function retrieveIntercomHelpCentersPermissions({
});
const collectionNodes: ContentNode[] = collectionsInDb.map(
(collection) => ({
provider: connector.type,
internalId: getHelpCenterCollectionInternalId(
connectorId,
collection.collectionId
Expand Down Expand Up @@ -522,7 +517,6 @@ export async function retrieveIntercomHelpCentersPermissions({
},
});
const articleNodes: ContentNode[] = articlesInDb.map((article) => ({
provider: connector.type,
internalId: getHelpCenterArticleInternalId(
connectorId,
article.articleId
Expand Down
3 changes: 0 additions & 3 deletions connectors/src/connectors/intercom/lib/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export async function retrieveSelectedNodes({
);

collectionsNodes.push({
provider: connector.type,
internalId: getHelpCenterCollectionInternalId(
connectorId,
collection.collectionId
Expand Down Expand Up @@ -79,7 +78,6 @@ export async function retrieveSelectedNodes({
intercomWorkspace?.syncAllConversations === "scheduled_activate"
) {
teamsNodes.push({
provider: connector.type,
internalId: getTeamsInternalId(connectorId),
parentInternalId: null,
type: "channel",
Expand All @@ -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",
Expand Down
Loading

0 comments on commit eb11617

Please sign in to comment.