-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Start setting up test * Project converter * Start sprint converter * Support multiple records with same id in stream context * Finish sprint converter * Fix test * Add epic records and update issue records * Remove epicissues * Start epics converter * Finish epics converter * Users converter * Add config to converters * Project board ownership * Issues * Issue dependencies * Refactor * Changelogs * Update * TODOs * Revert "Support multiple records with same id in stream context" This reverts commit cdc8afc. * Finally * Update package.json * Jira PG * Move jira resources to own folder * Move config to StreamContext * Use existing function * Use dicts * Remove extra tests * Use config object * Move interfaces to common * Remove extra converters * Revert "Remove extra converters" This reverts commit df8d8eb. * Add board_issues * Address comments
- Loading branch information
Showing
64 changed files
with
2,839 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
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
16 changes: 16 additions & 0 deletions
16
destinations/faros-destination/src/converters/jira/application_roles.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,16 @@ | ||
import {AirbyteRecord} from 'faros-airbyte-cdk'; | ||
|
||
import {DestinationModel, DestinationRecord, StreamContext} from '../converter'; | ||
import {JiraConverter} from './common'; | ||
|
||
export class JiraApplicationRoles extends JiraConverter { | ||
readonly destinationModels: ReadonlyArray<DestinationModel> = []; // TODO: set destination model | ||
|
||
convert( | ||
record: AirbyteRecord, | ||
ctx: StreamContext | ||
): ReadonlyArray<DestinationRecord> { | ||
// TODO: convert records | ||
return []; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
destinations/faros-destination/src/converters/jira/avatars.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,16 @@ | ||
import {AirbyteRecord} from 'faros-airbyte-cdk'; | ||
|
||
import {DestinationModel, DestinationRecord, StreamContext} from '../converter'; | ||
import {JiraConverter} from './common'; | ||
|
||
export class JiraAvatars extends JiraConverter { | ||
readonly destinationModels: ReadonlyArray<DestinationModel> = []; // TODO: set destination model | ||
|
||
convert( | ||
record: AirbyteRecord, | ||
ctx: StreamContext | ||
): ReadonlyArray<DestinationRecord> { | ||
// TODO: convert records | ||
return []; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
destinations/faros-destination/src/converters/jira/board_issues.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,28 @@ | ||
import {AirbyteRecord} from 'faros-airbyte-cdk'; | ||
|
||
import {DestinationModel, DestinationRecord, StreamContext} from '../converter'; | ||
import {JiraConverter} from './common'; | ||
|
||
export class JiraBoardIssues extends JiraConverter { | ||
readonly destinationModels: ReadonlyArray<DestinationModel> = [ | ||
'tms_TaskBoardRelationship', | ||
]; | ||
|
||
convert( | ||
record: AirbyteRecord, | ||
ctx: StreamContext | ||
): ReadonlyArray<DestinationRecord> { | ||
if (!this.useBoardOwnership(ctx)) return []; | ||
const issue = record.record.data; | ||
const source = this.streamName.source; | ||
return [ | ||
{ | ||
model: 'tms_TaskBoardRelationship', | ||
record: { | ||
task: {uid: issue.key, source}, | ||
board: {uid: String(issue.boardId), source}, | ||
}, | ||
}, | ||
]; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
destinations/faros-destination/src/converters/jira/boards.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,34 @@ | ||
import {AirbyteRecord} from 'faros-airbyte-cdk'; | ||
|
||
import {DestinationModel, DestinationRecord, StreamContext} from '../converter'; | ||
import {JiraConverter} from './common'; | ||
|
||
export class JiraBoards extends JiraConverter { | ||
readonly destinationModels: ReadonlyArray<DestinationModel> = [ | ||
'tms_TaskBoard', | ||
'tms_TaskBoardProjectRelationship', | ||
]; | ||
|
||
convert( | ||
record: AirbyteRecord, | ||
ctx: StreamContext | ||
): ReadonlyArray<DestinationRecord> { | ||
if (!this.useBoardOwnership(ctx)) return []; | ||
const board = record.record.data; | ||
const uid = board.id.toString(); | ||
const source = this.streamName.source; | ||
return [ | ||
{ | ||
model: 'tms_TaskBoard', | ||
record: {uid, name: board.name, source}, | ||
}, | ||
{ | ||
model: 'tms_TaskBoardProjectRelationship', | ||
record: { | ||
board: {uid, source}, | ||
project: {uid: board.projectKey, source}, | ||
}, | ||
}, | ||
]; | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
destinations/faros-destination/src/converters/jira/common.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,74 @@ | ||
import {AirbyteRecord} from 'faros-airbyte-cdk'; | ||
import {Dictionary} from 'ts-essentials'; | ||
|
||
import {Converter, StreamContext} from '../converter'; | ||
|
||
export interface Assignee { | ||
readonly uid: string; | ||
readonly assignedAt: Date; | ||
} | ||
|
||
export enum RepoSource { | ||
BITBUCKET = 'Bitbucket', | ||
GITHUB = 'GitHub', | ||
GITLAB = 'GitLab', | ||
VCS = 'VCS', | ||
} | ||
|
||
export interface Repo { | ||
readonly source: RepoSource; | ||
readonly org: string; | ||
readonly name: string; | ||
} | ||
|
||
export interface PullRequest { | ||
readonly repo: Repo; | ||
readonly number: number; | ||
} | ||
|
||
export interface Status { | ||
readonly category: string; | ||
readonly detail: string; | ||
} | ||
|
||
export interface SprintIssue { | ||
id: number; | ||
key: string; | ||
fields: Dictionary<any>; | ||
issueId: string; | ||
sprintId: number; | ||
} | ||
|
||
export class JiraCommon { | ||
static POINTS_FIELD_NAMES = ['Story Points', 'Story point estimate']; | ||
static DEV_FIELD_NAME = 'Development'; | ||
static EPIC_LINK_FIELD_NAME = 'Epic Link'; | ||
static SPRINT_FIELD_NAME = 'Sprint'; | ||
|
||
static normalize(str: string): string { | ||
return str.replace(/\s/g, '').toLowerCase(); | ||
} | ||
} | ||
|
||
export const JiraStatusCategories: ReadonlyMap<string, string> = new Map( | ||
['Todo', 'InProgress', 'Done'].map((s) => [JiraCommon.normalize(s), s]) | ||
); | ||
|
||
export interface JiraConfig { | ||
use_board_ownership?: boolean; | ||
} | ||
|
||
export abstract class JiraConverter extends Converter { | ||
/** All Jira records should have id property */ | ||
id(record: AirbyteRecord): any { | ||
return record?.record?.data?.id; | ||
} | ||
|
||
protected jiraConfig(ctx: StreamContext): JiraConfig { | ||
return ctx.config.source_specific_configs?.jira ?? {}; | ||
} | ||
|
||
protected useBoardOwnership(ctx: StreamContext): boolean { | ||
return this.jiraConfig(ctx).use_board_ownership ?? false; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
destinations/faros-destination/src/converters/jira/dashboards.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,16 @@ | ||
import {AirbyteRecord} from 'faros-airbyte-cdk'; | ||
|
||
import {DestinationModel, DestinationRecord, StreamContext} from '../converter'; | ||
import {JiraConverter} from './common'; | ||
|
||
export class JiraDashboards extends JiraConverter { | ||
readonly destinationModels: ReadonlyArray<DestinationModel> = []; // TODO: set destination model | ||
|
||
convert( | ||
record: AirbyteRecord, | ||
ctx: StreamContext | ||
): ReadonlyArray<DestinationRecord> { | ||
// TODO: convert records | ||
return []; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
destinations/faros-destination/src/converters/jira/epics.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,50 @@ | ||
import {AirbyteRecord} from 'faros-airbyte-cdk'; | ||
import TurndownService from 'turndown'; | ||
|
||
import { | ||
DestinationModel, | ||
DestinationRecord, | ||
StreamContext, | ||
StreamName, | ||
} from '../converter'; | ||
import {JiraCommon, JiraConverter, JiraStatusCategories} from './common'; | ||
|
||
export class JiraEpics extends JiraConverter { | ||
readonly destinationModels: ReadonlyArray<DestinationModel> = ['tms_Epic']; | ||
|
||
private turndown = new TurndownService(); | ||
|
||
convert( | ||
record: AirbyteRecord, | ||
ctx: StreamContext | ||
): ReadonlyArray<DestinationRecord> { | ||
const epic = record.record.data; | ||
const source = this.streamName.source; | ||
const status = epic.fields.status ?? {}; | ||
let description = null; | ||
if (typeof epic.fields.description === 'string') { | ||
description = epic.fields.description; | ||
} else if (epic.renderedFields.description) { | ||
description = this.turndown.turndown(epic.renderedFields.description); | ||
} | ||
|
||
return [ | ||
{ | ||
model: 'tms_Epic', | ||
record: { | ||
uid: epic.key, | ||
name: epic.fields.summary ?? null, | ||
description, | ||
status: { | ||
category: JiraStatusCategories.get( | ||
JiraCommon.normalize(status.statusCategory?.name) | ||
), | ||
detail: status.name, | ||
}, | ||
project: {uid: epic.projectKey, source}, | ||
source, | ||
}, | ||
}, | ||
]; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
destinations/faros-destination/src/converters/jira/filter_sharing.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,16 @@ | ||
import {AirbyteRecord} from 'faros-airbyte-cdk'; | ||
|
||
import {DestinationModel, DestinationRecord, StreamContext} from '../converter'; | ||
import {JiraConverter} from './common'; | ||
|
||
export class JiraFilterSharing extends JiraConverter { | ||
readonly destinationModels: ReadonlyArray<DestinationModel> = []; // TODO: set destination model | ||
|
||
convert( | ||
record: AirbyteRecord, | ||
ctx: StreamContext | ||
): ReadonlyArray<DestinationRecord> { | ||
// TODO: convert records | ||
return []; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
destinations/faros-destination/src/converters/jira/filters.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,16 @@ | ||
import {AirbyteRecord} from 'faros-airbyte-cdk'; | ||
|
||
import {DestinationModel, DestinationRecord, StreamContext} from '../converter'; | ||
import {JiraConverter} from './common'; | ||
|
||
export class JiraFilters extends JiraConverter { | ||
readonly destinationModels: ReadonlyArray<DestinationModel> = []; // TODO: set destination model | ||
|
||
convert( | ||
record: AirbyteRecord, | ||
ctx: StreamContext | ||
): ReadonlyArray<DestinationRecord> { | ||
// TODO: convert records | ||
return []; | ||
} | ||
} |
Oops, something went wrong.