Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[KW-search] Enforce always passing parentId in connectors #9580

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

aubin-tchoi
Copy link
Contributor

@aubin-tchoi aubin-tchoi commented Dec 20, 2024

Description

  • Closes half of [KW-search] Enforce always passing parent id (core, connectors) #9365 (will do core in an upcoming PR).
  • Pass parentId at every location where they were missing.
  • Make parentId mandatory on the interface from connectors to api/v1.
  • Improve types for the parents when applicable (e.g. add tuples when possible explicitely).
  • I updated the migration scripts to please the linter.

Risk

  • Should be at the typing level, if it builds no behavior change is expected.

Deploy Plan

  • Deploy connectors.

Comment on lines +197 to +200
return [
getHelpCenterCollectionInternalId(connectorId, collectionId),
...parentIds,
getHelpCenterInternalId(connectorId, helpCenterId),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed this purely to allow typing it as a tuple

@@ -228,7 +228,7 @@ export async function upsertCollectionWithChildren({
folderId: internalCollectionId,
title: collection.name,
parents: collectionParents,
parentId: collectionParents.length > 2 ? collectionParents[1] : null,
parentId: collectionParents[1],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the type now shows, we at least have [collectionInternalId, ...maybe some parent collections, helpCenterInternalId], which is why this is correct

Copy link
Contributor

@spolu spolu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great other than the type weirdness in the case of having only one parent?

@@ -252,7 +253,7 @@ export async function markPageHasVisited({
interface ConfluenceUpsertPageInput {
page: NonNullable<Awaited<ReturnType<ConfluenceClient["getPageById"]>>>;
spaceName: string;
parents: string[];
parents: [string, ...string[], string];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is weird 🙃

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if I have only one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can't, i'm trying to enforce a Confluence logic rule that there's always gonna be the internalId and the spaceID (or the hidden node thing if parents are not already computed)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right it's confluence 👍 Thought it was datasource.ts

@aubin-tchoi aubin-tchoi requested review from philipperolet and removed request for philipperolet December 23, 2024 18:32
Copy link
Contributor

@philipperolet philipperolet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 🔥
Left mininits

@@ -252,7 +253,7 @@ export async function markPageHasVisited({
interface ConfluenceUpsertPageInput {
page: NonNullable<Awaited<ReturnType<ConfluenceClient["getPageById"]>>>;
spaceName: string;
parents: string[];
parents: [string, ...string[], string];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume confluence activities were already passing parentIds appropriately

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(as per pr description actually :))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes correct

@@ -149,7 +149,7 @@ export async function getParentIdsForArticle({
connectorId: number;
parentCollectionId: string;
helpCenterId: string;
}) {
}): Promise<[string, string, ...string[], string]> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume articles can't be at the root of a help center (not inside a collection), correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting one, AFAICT it is possible to create an orphaned article in Intercom by deleting the collection but these are not displayed correctly in Intercom nor in our connector

Copy link
Contributor Author

@aubin-tchoi aubin-tchoi Dec 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And we don't fetch orphaned articles (we make the assumption that we have a collection everywhere) so the type is valid here 👍

@@ -477,6 +478,7 @@ export async function syncFiles({
dataSourceConfig,
folderId: createdOrUpdatedResource.internalId,
parents: [createdOrUpdatedResource.internalId, ...parents],
parentId: parents[0],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: parents[1] everywhere in connectors, except here parents[0], is a bit confounding

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

especially with parents[1] in the same file a bit below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I initially wrote it that way to keep the diff small, I'll change it now that it's been reviewed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants