Add resync on integration import creation/deletion and update forward/backward recursive logic for syncing dependent imports

This commit is contained in:
Tuan Dang
2024-04-10 21:18:26 -07:00
parent f255d891ae
commit 85489a81ff
4 changed files with 85 additions and 59 deletions
@@ -259,10 +259,12 @@ export const secretFolderDALFactory = (db: TDbClient) => {
const findSecretPathByFolderIds = async (projectId: string, folderIds: string[], tx?: Knex) => {
try {
const folders = await sqlFindSecretPathByFolderId(tx || db, projectId, folderIds);
const rootFolders = groupBy(
folders.filter(({ parentId }) => parentId === null),
(i) => i.child || i.id // root condition then child and parent will null
);
return folderIds.map((folderId) => rootFolders[folderId]?.[0]);
} catch (error) {
throw new DatabaseError({ error, name: "Find by secret path" });