-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CoreNodes] Hide certain folders when empty (Shared with me, Orphaned…
… Resources) (#10236) * add a specific mime type for google's Shared with me folder * add backfill script * add a filter on catch all folders * add the URL for the shared with me folder * rename CATCH_ALL_FOLDERS_ into FOLDERS_TO_HIDE_IF_EMPTY_
- Loading branch information
1 parent
b8728a8
commit bae93cd
Showing
7 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
connectors/migrations/20250127_backfill_gdrive_shared_with_me.ts
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { MIME_TYPES } from "@dust-tt/types"; | ||
import { makeScript } from "scripts/helpers"; | ||
|
||
import { | ||
GOOGLE_DRIVE_SHARED_WITH_ME_VIRTUAL_ID, | ||
GOOGLE_DRIVE_SHARED_WITH_ME_WEB_URL, | ||
} from "@connectors/connectors/google_drive/lib/consts"; | ||
import { getInternalId } from "@connectors/connectors/google_drive/temporal/utils"; | ||
import { dataSourceConfigFromConnector } from "@connectors/lib/api/data_source_config"; | ||
import { concurrentExecutor } from "@connectors/lib/async_utils"; | ||
import { upsertDataSourceFolder } from "@connectors/lib/data_sources"; | ||
import { ConnectorResource } from "@connectors/resources/connector_resource"; | ||
|
||
makeScript({}, async ({ execute }, logger) => { | ||
const connectors = await ConnectorResource.listByType("google_drive", {}); | ||
|
||
await concurrentExecutor( | ||
connectors, | ||
async (connector) => { | ||
const folderId = getInternalId(GOOGLE_DRIVE_SHARED_WITH_ME_VIRTUAL_ID); | ||
if (execute) { | ||
await upsertDataSourceFolder({ | ||
dataSourceConfig: dataSourceConfigFromConnector(connector), | ||
folderId, | ||
parents: [folderId], | ||
parentId: null, | ||
title: "Shared with me", | ||
mimeType: MIME_TYPES.GOOGLE_DRIVE.SHARED_WITH_ME, | ||
sourceUrl: GOOGLE_DRIVE_SHARED_WITH_ME_WEB_URL, | ||
}); | ||
logger.info( | ||
`Upserted folder ${folderId} for connector ${connector.id}` | ||
); | ||
} else { | ||
logger.info( | ||
`Would upsert folder ${folderId} for connector ${connector.id}` | ||
); | ||
} | ||
}, | ||
{ concurrency: 10 } | ||
); | ||
}); |
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
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