Skip to content

Commit

Permalink
👕
Browse files Browse the repository at this point in the history
  • Loading branch information
flvndvd committed Jan 16, 2024
1 parent 941294e commit a8da464
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ async function main() {

console.log(`Connector ${c.id}: found ${files.length} files`);

const fileHash = files.reduce(
(acc, f) => {
acc[f.dustFileId] = f.id;
return acc;
},
{} as { [key: string]: number }
);
const fileHash = files.reduce((acc, f) => {
acc[f.dustFileId] = f.id;
return acc;
}, {} as { [key: string]: number });

// find dustProjectId from front based on workspaceId and connectorName
const dsData = await front_sequelize.query(
Expand Down
11 changes: 4 additions & 7 deletions connectors/src/api/slack_channels_linked_with_agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,10 @@ const _patchSlackChannelsLinkedWithAgentHandler = async (
const remoteChannels = (
await getChannels(parseInt(connectorId), false)
).flatMap((c) => (c.id && c.name ? [{ id: c.id, name: c.name }] : []));
const remoteChannelsById = remoteChannels.reduce(
(acc, ch) => {
acc[ch.id] = ch;
return acc;
},
{} as Record<string, { id: string; name: string }>
);
const remoteChannelsById = remoteChannels.reduce((acc, ch) => {
acc[ch.id] = ch;
return acc;
}, {} as Record<string, { id: string; name: string }>);
const createdChannels = await Promise.all(
missingSlackChannelIds.map((slackChannelId) => {
const remoteChannel = remoteChannelsById[slackChannelId];
Expand Down
11 changes: 4 additions & 7 deletions connectors/src/connectors/google_drive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,13 +616,10 @@ export async function retrieveGoogleDriveObjectsTitles(
},
});

const titles = googleDriveFiles.reduce(
(acc, curr) => {
acc[curr.driveFileId] = curr.name;
return acc;
},
{} as Record<string, string>
);
const titles = googleDriveFiles.reduce((acc, curr) => {
acc[curr.driveFileId] = curr.name;
return acc;
}, {} as Record<string, string>);

return new Ok(titles);
}
Expand Down
11 changes: 4 additions & 7 deletions connectors/src/connectors/notion/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,10 @@ export async function retrieveNotionResourcesTitles(
.concat(
dbs.map((db) => ({ internalId: db.notionDatabaseId, title: db.title }))
)
.reduce(
(acc, { internalId, title }) => {
acc[internalId] = title ?? null;
return acc;
},
{} as Record<string, string | null>
);
.reduce((acc, { internalId, title }) => {
acc[internalId] = title ?? null;
return acc;
}, {} as Record<string, string | null>);

return new Ok(titles);
}
Expand Down
5 changes: 3 additions & 2 deletions connectors/src/connectors/notion/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ export async function searchNotionPagesForQuery({
page_size: 20,
});

const skippedDatabaseIds =
await listSkippedDatabaseIdsForConnectorId(connectorId);
const skippedDatabaseIds = await listSkippedDatabaseIdsForConnectorId(
connectorId
);

return pages.results.map((p) => ({
id: p.id,
Expand Down
2 changes: 1 addition & 1 deletion connectors/src/connectors/notion/lib/notion_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ export async function* iteratePaginatedAPIWithRetries<
Args extends {
start_cursor?: string;
},
Item,
Item
>(
listFn: (args: Args) => Promise<IPaginatedList<Item>>,
firstPageArgs: Args,
Expand Down
11 changes: 4 additions & 7 deletions connectors/src/connectors/notion/temporal/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1578,13 +1578,10 @@ export async function renderAndUpsertPageFromCache({
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
b.childDatabaseTitle!,
}))
.reduce(
(acc, { id, title }) => {
acc[id] = title;
return acc;
},
{} as Record<string, string>
);
.reduce((acc, { id, title }) => {
acc[id] = title;
return acc;
}, {} as Record<string, string>);

localLogger.info(
"notionRenderAndUpsertPageFromCache: Retrieving child database pages from cache."
Expand Down
9 changes: 5 additions & 4 deletions connectors/src/connectors/notion/temporal/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ export async function notionSyncWorkflow({
runType: isGarbageCollectionRun
? "garbageCollection"
: isInitialSync
? "initialSync"
: "incrementalSync",
? "initialSync"
: "incrementalSync",
},
});
cursor = nextCursor;
Expand Down Expand Up @@ -157,8 +157,9 @@ export async function notionSyncWorkflow({
// these are resources (pages/DBs) that we didn't get from the search API but that are child pages/DBs
// of other pages that we did get from the search API.
// We upsert those as well.
const discoveredResources =
await getDiscoveredResourcesFromCache(connectorId);
const discoveredResources = await getDiscoveredResourcesFromCache(
connectorId
);
await performUpserts({
connectorId,
pageIds: discoveredResources.pageIds,
Expand Down
11 changes: 4 additions & 7 deletions connectors/src/connectors/slack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,10 @@ export async function retrieveSlackConnectorPermissions({
},
}),
]);
const localChannelsById = localChannels.reduce(
(acc, ch) => {
acc[ch.slackChannelId] = ch;
return acc;
},
{} as Record<string, SlackChannel>
);
const localChannelsById = localChannels.reduce((acc, ch) => {
acc[ch.slackChannelId] = ch;
return acc;
}, {} as Record<string, SlackChannel>);

for (const remoteChannel of remoteChannels) {
if (!remoteChannel.id || !remoteChannel.name) {
Expand Down
11 changes: 4 additions & 7 deletions connectors/src/connectors/webcrawler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,10 @@ export async function retrieveWebCrawlerObjectsTitles(
},
});

const titles = googleDriveFiles.reduce(
(acc, curr) => {
acc[curr.url] = curr.url;
return acc;
},
{} as Record<string, string>
);
const titles = googleDriveFiles.reduce((acc, curr) => {
acc[curr.url] = curr.url;
return acc;
}, {} as Record<string, string>);

return new Ok(titles);
}
Expand Down
5 changes: 3 additions & 2 deletions connectors/src/lib/temporal_monitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ export class ActivityInboundLogInterceptor
if (connectorId) {
await syncFailed(connectorId, "oauth_token_revoked");

const doNotCancelOnTokenRevoked =
await getDoNotCancelOnTokenRevoked(workflowId);
const doNotCancelOnTokenRevoked = await getDoNotCancelOnTokenRevoked(
workflowId
);
if (doNotCancelOnTokenRevoked) {
this.logger.info(
"Skipping cancelling workflow because of expired token."
Expand Down

0 comments on commit a8da464

Please sign in to comment.