-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[connectors] update Confluence to use new internalIDs in content node…
…s and upsertions (#9337) * refactor: use new IDs everywhere (content nodes + upsertions) * fix imports
- Loading branch information
1 parent
6b31102
commit 47c8f03
Showing
8 changed files
with
62 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,39 @@ | ||
import { | ||
makeConfluencePageId, | ||
makeConfluenceSpaceId, | ||
} from "@connectors/connectors/confluence/temporal/utils"; | ||
/** | ||
Naming conventions: | ||
- Confluence ID: The ID that Confluence uses to identify a space or page, usually just a number. | ||
- Internal ID: The ID we use in content nodes and in data_source_documents (both document_id and parents). | ||
Internal IDs are Confluence IDs with a prefix `confluence-space-` or `confluence-page-`. | ||
*/ | ||
|
||
enum ConfluenceInternalIdPrefix { | ||
Space = "cspace_", | ||
Page = "cpage_", | ||
Space = "confluence-space-", | ||
Page = "confluence-page", | ||
} | ||
|
||
export function makeConfluenceInternalSpaceId(confluenceSpaceId: string) { | ||
export function makeSpaceInternalId(confluenceSpaceId: string) { | ||
return `${ConfluenceInternalIdPrefix.Space}${confluenceSpaceId}`; | ||
} | ||
|
||
export function makeConfluenceInternalPageId(confluencePageId: string) { | ||
export function makePageInternalId(confluencePageId: string) { | ||
return `${ConfluenceInternalIdPrefix.Page}${confluencePageId}`; | ||
} | ||
|
||
export function getIdFromConfluenceInternalId(internalId: string) { | ||
const prefixPattern = `^(${ConfluenceInternalIdPrefix.Space}|${ConfluenceInternalIdPrefix.Page})`; | ||
return internalId.replace(new RegExp(prefixPattern), ""); | ||
export function getConfluenceIdFromInternalId(internalId: string) { | ||
if (isInternalPageId(internalId) || isInternalSpaceId(internalId)) { | ||
const prefixPattern = `^(${ConfluenceInternalIdPrefix.Space}|${ConfluenceInternalIdPrefix.Page})`; | ||
return internalId.replace(new RegExp(prefixPattern), ""); | ||
} | ||
throw new Error(`Invalid internal ID: ${internalId}`); | ||
} | ||
|
||
export function isConfluenceInternalSpaceId( | ||
export function isInternalSpaceId( | ||
internalId: string | ||
): internalId is `${ConfluenceInternalIdPrefix.Space}${string}` { | ||
return internalId.startsWith(ConfluenceInternalIdPrefix.Space); | ||
} | ||
|
||
export function isConfluenceInternalPageId( | ||
export function isInternalPageId( | ||
internalId: string | ||
): internalId is `${ConfluenceInternalIdPrefix.Page}${string}` { | ||
return internalId.startsWith(ConfluenceInternalIdPrefix.Page); | ||
} | ||
|
||
export function convertInternalIdToDocumentId(internalId: string): string { | ||
if (isConfluenceInternalPageId(internalId)) { | ||
return makeConfluencePageId(getIdFromConfluenceInternalId(internalId)); | ||
} | ||
if (isConfluenceInternalSpaceId(internalId)) { | ||
return makeConfluenceSpaceId(getIdFromConfluenceInternalId(internalId)); | ||
} | ||
throw new Error(`Invalid internal ID: ${internalId}`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters