-
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] Add sync activities for Zendesk Articles and Tickets (#8305
) * refactor: rename the interfaces used to type the responses of the API * feat: add the db interaction in syncZendeskArticlesActivity * feat: implement ticket sync (db interaction only, no upsert) * feat: plug ticket sync on the existing workflow * chore: remove TODOs to stop Danger from panicking * perf: parallelize certain awaited promises * fix: remove an unused configuration * fix: remove an unused configuration * refactor: cleanup the makeNew methods
- Loading branch information
1 parent
44484cb
commit 0a18cc6
Showing
6 changed files
with
303 additions
and
50 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
56 changes: 56 additions & 0 deletions
56
connectors/src/connectors/zendesk/temporal/sync_article.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,56 @@ | ||
import type { ModelId } from "@dust-tt/types"; | ||
|
||
import type { ZendeskFetchedArticle } from "@connectors/connectors/zendesk/lib/node-zendesk-types"; | ||
import { ZendeskArticleResource } from "@connectors/resources/zendesk_resources"; | ||
import type { DataSourceConfig } from "@connectors/types/data_source_config"; | ||
|
||
export async function syncArticle({ | ||
connectorId, | ||
article, | ||
brandId, | ||
categoryId, | ||
currentSyncDateMs, | ||
}: { | ||
connectorId: ModelId; | ||
dataSourceConfig: DataSourceConfig; | ||
article: ZendeskFetchedArticle; | ||
brandId: number; | ||
categoryId: number; | ||
currentSyncDateMs: number; | ||
loggerArgs: Record<string, string | number | null>; | ||
forceResync: boolean; | ||
}) { | ||
let articleInDb = await ZendeskArticleResource.fetchByArticleId({ | ||
connectorId, | ||
articleId: article.id, | ||
}); | ||
const createdAtDate = new Date(article.created_at); | ||
const updatedAtDate = new Date(article.updated_at); | ||
|
||
if (!articleInDb) { | ||
articleInDb = await ZendeskArticleResource.makeNew({ | ||
blob: { | ||
createdAt: createdAtDate, | ||
updatedAt: updatedAtDate, | ||
articleId: article.id, | ||
brandId, | ||
categoryId, | ||
permission: "read", | ||
name: article.name, | ||
url: article.url, | ||
lastUpsertedTs: new Date(currentSyncDateMs), | ||
connectorId, | ||
}, | ||
}); | ||
} else { | ||
await articleInDb.update({ | ||
createdAt: createdAtDate, | ||
updatedAt: updatedAtDate, | ||
categoryId, // an article can be moved from one category to another, which does not apply to brands | ||
name: article.name, | ||
url: article.url, | ||
lastUpsertedTs: new Date(currentSyncDateMs), | ||
}); | ||
} | ||
/// TODO: upsert the article here | ||
} |
Oops, something went wrong.