Skip to content

Commit

Permalink
move the hidden content node logic to the Confluence connector
Browse files Browse the repository at this point in the history
  • Loading branch information
aubin-tchoi committed Dec 13, 2024
1 parent 090b0f4 commit d595bfb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
10 changes: 8 additions & 2 deletions connectors/src/connectors/confluence/temporal/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ import mainLogger from "@connectors/logger/logger";
import { ConnectorResource } from "@connectors/resources/connector_resource";
import type { DataSourceConfig } from "@connectors/types/data_source_config";

/**
* This type represents the ID that should be passed as parentId to a content node to hide it from the UI.
* This behavior is typically used to hide content nodes whose position in the ContentNodeTree cannot be resolved at time of upsertion.
*/
export const HiddenContentNodeParentId = "__internal_synchronizing__";

const logger = mainLogger.child({
provider: "confluence",
});
Expand Down Expand Up @@ -381,8 +387,8 @@ export async function confluenceCheckAndUpsertPageActivity({
documentUrl,
loggerArgs,
// Parent Ids will be computed after all page imports within the space have been completed.
parents: [documentId],
hideContentNode: true,
parents: [documentId, HiddenContentNodeParentId],
parentId: HiddenContentNodeParentId,
tags,
timestampMs: lastPageVersionCreatedAt.getTime(),
upsertContext: {
Expand Down
17 changes: 2 additions & 15 deletions connectors/src/lib/data_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
PostDataSourceDocumentRequestBody,
} from "@dust-tt/types";
import {
HiddenContentNodeParentId,
isValidDate,
MAX_CHUNK_SIZE,
safeSubstring,
Expand Down Expand Up @@ -70,15 +69,13 @@ type UpsertToDataSourceParams = {
timestampMs?: number;
tags?: string[];
parents: string[];
parentId?: string | null;
loggerArgs?: Record<string, string | number>;
upsertContext: UpsertContext;
title: string;
mimeType: string;
async: boolean;
} & (
| { parentId?: string | null; hideContentNode?: never } // TODO(2024-12-13) - parentId should not be nullable here, to change after changing the connectors
| { parentId?: never; hideContentNode: true }
);
};

function getDustAPI(dataSourceConfig: DataSourceConfig) {
return new DustAPI(
Expand Down Expand Up @@ -108,7 +105,6 @@ async function _upsertToDatasource({
mimeType,
async,
parentId = null,
hideContentNode,
}: UpsertToDataSourceParams) {
return tracer.trace(
`connectors`,
Expand Down Expand Up @@ -154,15 +150,6 @@ async function _upsertToDatasource({
? (Math.floor(timestampMs) as Branded<number, IntBrand>)
: null;

// setting the magic values to hide the content node
if (hideContentNode) {
parentId = HiddenContentNodeParentId; // types enforce that we don't already have a parentId there
parents = [
...parents.filter((p) => p !== HiddenContentNodeParentId),
HiddenContentNodeParentId,
];
}

const dustRequestPayload: PostDataSourceDocumentRequestBody = {
text: null,
section: documentContent,
Expand Down
10 changes: 0 additions & 10 deletions types/src/front/lib/connectors_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,6 @@ export type ContentNodeWithParentIds = ContentNode & {
parentInternalIds: string[] | null;
};

/**
* This type represents the ID that should be passed as parentId to a content node to hide it from the UI.
* This behavior is typically used to hide content nodes whose position in the ContentNodeTree cannot be resolved at time of upsertion.
*/
export const HiddenContentNodeParentId = "__dust_synchronizing__";

export function isContentNodeHidden(contentNode: BaseContentNode): boolean {
return contentNode.parentInternalId === HiddenContentNodeParentId;
}

type GetContentNodesReturnType<
IncludeParents extends boolean,
Key extends string
Expand Down

0 comments on commit d595bfb

Please sign in to comment.