diff --git a/destinations/airbyte-faros-destination/src/converters/github/team_memberships.ts b/destinations/airbyte-faros-destination/src/converters/github/team_memberships.ts new file mode 100644 index 000000000..bef3d4dcc --- /dev/null +++ b/destinations/airbyte-faros-destination/src/converters/github/team_memberships.ts @@ -0,0 +1,44 @@ +import {AirbyteRecord} from 'faros-airbyte-cdk'; +import {toLower} from 'lodash'; + +import {DestinationModel, DestinationRecord} from '../converter'; +import {GitHubConverter} from './common'; + +export class TeamMemberships extends GitHubConverter { + readonly destinationModels: ReadonlyArray = [ + 'vcs_TeamMembership', + 'vcs_User', + ]; + + async convert( + record: AirbyteRecord + ): Promise> { + const source = this.streamName.source; + const membership = record.record.data; + const res: DestinationRecord[] = []; + + const team = { + uid: toLower(membership.team_slug), + source, + }; + const user = { + uid: toLower(membership.username), + source, + }; + + res.push({ + model: 'vcs_User', + record: user, + }); + + res.push({ + model: 'vcs_TeamMembership', + record: { + user, + team, + }, + }); + + return res; + } +} diff --git a/destinations/airbyte-faros-destination/src/converters/github/teams.ts b/destinations/airbyte-faros-destination/src/converters/github/teams.ts new file mode 100644 index 000000000..9d594984d --- /dev/null +++ b/destinations/airbyte-faros-destination/src/converters/github/teams.ts @@ -0,0 +1,29 @@ +import {AirbyteRecord} from 'faros-airbyte-cdk'; +import {toLower} from 'lodash'; + +import {DestinationModel, DestinationRecord} from '../converter'; +import {GitHubConverter} from './common'; + +export class Teams extends GitHubConverter { + readonly destinationModels: ReadonlyArray = ['vcs_Team']; + + async convert( + record: AirbyteRecord + ): Promise> { + const source = this.streamName.source; + const team = record.record.data; + const res: DestinationRecord[] = []; + + res.push({ + model: 'vcs_Team', + record: { + name: team.name, + uid: toLower(team.slug), + description: team.description, + source, + }, + }); + + return res; + } +}