airbyte-faros-destination 0.1.74 → 0.1.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/converters/azure-repos/common.d.ts +17 -0
- package/lib/converters/azure-repos/common.js +72 -0
- package/lib/converters/azure-repos/models.d.ts +217 -0
- package/lib/converters/azure-repos/models.js +32 -0
- package/lib/converters/azure-repos/pull_requests.d.ts +7 -0
- package/lib/converters/azure-repos/pull_requests.js +82 -0
- package/lib/converters/azure-repos/repositories.d.ts +8 -0
- package/lib/converters/azure-repos/repositories.js +109 -0
- package/lib/converters/azure-repos/users.d.ts +7 -0
- package/lib/converters/azure-repos/users.js +44 -0
- package/lib/converters/bitbucket/pipelines.js +5 -1
- package/lib/converters/buildkite/builds.js +1 -1
- package/lib/converters/{gitlab/common.d.ts → common/gitlab.d.ts} +5 -0
- package/lib/converters/{gitlab/common.js → common/gitlab.js} +9 -0
- package/lib/converters/github/assignees.js +4 -1
- package/lib/converters/github/common.d.ts +1 -1
- package/lib/converters/github/common.js +2 -0
- package/lib/converters/github/issues.js +12 -12
- package/lib/converters/gitlab/branches.d.ts +1 -1
- package/lib/converters/gitlab/branches.js +3 -3
- package/lib/converters/gitlab/commits.d.ts +1 -1
- package/lib/converters/gitlab/commits.js +3 -3
- package/lib/converters/gitlab/group_labels.d.ts +1 -1
- package/lib/converters/gitlab/group_labels.js +2 -2
- package/lib/converters/gitlab/group_milestones.d.ts +1 -1
- package/lib/converters/gitlab/group_milestones.js +4 -4
- package/lib/converters/gitlab/groups.d.ts +1 -1
- package/lib/converters/gitlab/groups.js +3 -3
- package/lib/converters/gitlab/issues.d.ts +1 -1
- package/lib/converters/gitlab/issues.js +3 -3
- package/lib/converters/gitlab/jobs.d.ts +1 -1
- package/lib/converters/gitlab/jobs.js +4 -4
- package/lib/converters/gitlab/merge_request_commits.d.ts +1 -1
- package/lib/converters/gitlab/merge_request_commits.js +4 -4
- package/lib/converters/gitlab/merge_requests.d.ts +1 -1
- package/lib/converters/gitlab/merge_requests.js +3 -3
- package/lib/converters/gitlab/pipelines.d.ts +1 -1
- package/lib/converters/gitlab/pipelines.js +4 -4
- package/lib/converters/gitlab/project_labels.d.ts +1 -1
- package/lib/converters/gitlab/project_labels.js +2 -2
- package/lib/converters/gitlab/project_milestones.d.ts +1 -1
- package/lib/converters/gitlab/project_milestones.js +4 -4
- package/lib/converters/gitlab/projects.d.ts +1 -1
- package/lib/converters/gitlab/projects.js +6 -6
- package/lib/converters/gitlab/releases.d.ts +1 -1
- package/lib/converters/gitlab/releases.js +2 -2
- package/lib/converters/gitlab/tags.d.ts +1 -1
- package/lib/converters/gitlab/tags.js +3 -3
- package/lib/converters/gitlab/users.d.ts +1 -1
- package/lib/converters/gitlab/users.js +2 -2
- package/lib/converters/gitlab-ci/groups.d.ts +8 -0
- package/lib/converters/gitlab-ci/groups.js +31 -0
- package/lib/converters/gitlab-ci/jobs.d.ts +12 -0
- package/lib/converters/gitlab-ci/jobs.js +71 -0
- package/lib/converters/gitlab-ci/pipelines.d.ts +8 -0
- package/lib/converters/gitlab-ci/pipelines.js +48 -0
- package/lib/converters/gitlab-ci/projects.d.ts +8 -0
- package/lib/converters/gitlab-ci/projects.js +34 -0
- package/lib/converters/jenkins/builds.js +1 -1
- package/lib/converters/statuspage/common.d.ts +5 -5
- package/lib/converters/statuspage/common.js +6 -6
- package/lib/converters/statuspage/incident_updates.d.ts +2 -2
- package/lib/converters/statuspage/incident_updates.js +1 -1
- package/lib/converters/statuspage/incidents.d.ts +2 -2
- package/lib/converters/statuspage/incidents.js +3 -3
- package/lib/converters/statuspage/users.d.ts +2 -2
- package/lib/converters/statuspage/users.js +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/resources/spec.json +5 -5
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { Converter } from '../converter';
|
|
3
|
+
import { PullRequestReviewState, PullRequestState } from './models';
|
|
4
|
+
export declare type ApplicationMapping = Record<string, {
|
|
5
|
+
name: string;
|
|
6
|
+
platform?: string;
|
|
7
|
+
}>;
|
|
8
|
+
/** Azurerepos converter base */
|
|
9
|
+
export declare abstract class AzureReposConverter extends Converter {
|
|
10
|
+
source: string;
|
|
11
|
+
/** Almost every Azurerepos record have id property */
|
|
12
|
+
id(record: AirbyteRecord): any;
|
|
13
|
+
getOrganizationFromUrl(url: string): string;
|
|
14
|
+
convertStringToNumber(str: string): number;
|
|
15
|
+
convertPullRequestState(status: string): PullRequestState;
|
|
16
|
+
convertPullRequestReviewState(vote: number): PullRequestReviewState;
|
|
17
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AzureReposConverter = void 0;
|
|
4
|
+
const converter_1 = require("../converter");
|
|
5
|
+
const models_1 = require("./models");
|
|
6
|
+
/** Azurerepos converter base */
|
|
7
|
+
class AzureReposConverter extends converter_1.Converter {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.source = 'Azure-Repos';
|
|
11
|
+
}
|
|
12
|
+
/** Almost every Azurerepos record have id property */
|
|
13
|
+
id(record) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
return (_b = (_a = record === null || record === void 0 ? void 0 : record.record) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.id;
|
|
16
|
+
}
|
|
17
|
+
getOrganizationFromUrl(url) {
|
|
18
|
+
return url.split('/')[3];
|
|
19
|
+
}
|
|
20
|
+
convertStringToNumber(str) {
|
|
21
|
+
const lastString = str.split('-')[str.split('-').length - 1];
|
|
22
|
+
const onlyNumbers = lastString.replace(/[^\d.-]/g, '');
|
|
23
|
+
return Number(onlyNumbers);
|
|
24
|
+
}
|
|
25
|
+
//https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull-requests/get-pull-requests?view=azure-devops-rest-4.1#pullrequeststatus
|
|
26
|
+
convertPullRequestState(status) {
|
|
27
|
+
switch (status) {
|
|
28
|
+
case 'completed':
|
|
29
|
+
return {
|
|
30
|
+
category: models_1.PullRequestStateCategory.Closed,
|
|
31
|
+
detail: status,
|
|
32
|
+
};
|
|
33
|
+
case 'active':
|
|
34
|
+
return {
|
|
35
|
+
category: models_1.PullRequestStateCategory.Merged,
|
|
36
|
+
detail: status,
|
|
37
|
+
};
|
|
38
|
+
case 'notSet':
|
|
39
|
+
return {
|
|
40
|
+
category: models_1.PullRequestStateCategory.Open,
|
|
41
|
+
detail: status,
|
|
42
|
+
};
|
|
43
|
+
default:
|
|
44
|
+
return {
|
|
45
|
+
category: models_1.PullRequestStateCategory.Custom,
|
|
46
|
+
detail: status,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
convertPullRequestReviewState(vote) {
|
|
51
|
+
if (vote > 5)
|
|
52
|
+
return {
|
|
53
|
+
category: models_1.PullRequestReviewStateCategory.Approved,
|
|
54
|
+
detail: `vote ${vote}`,
|
|
55
|
+
};
|
|
56
|
+
if (vote > 0)
|
|
57
|
+
return {
|
|
58
|
+
category: models_1.PullRequestReviewStateCategory.Commented,
|
|
59
|
+
detail: `vote ${vote}`,
|
|
60
|
+
};
|
|
61
|
+
if (vote > -5)
|
|
62
|
+
return {
|
|
63
|
+
category: models_1.PullRequestReviewStateCategory.Custom,
|
|
64
|
+
detail: `vote ${vote}`,
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
category: models_1.PullRequestReviewStateCategory.Dismissed,
|
|
68
|
+
detail: `vote ${vote}`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.AzureReposConverter = AzureReposConverter;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
interface Project {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
url: string;
|
|
5
|
+
description: string;
|
|
6
|
+
state: string;
|
|
7
|
+
revision: number;
|
|
8
|
+
visibility: string;
|
|
9
|
+
lastUpdateTime: string;
|
|
10
|
+
}
|
|
11
|
+
interface Creator {
|
|
12
|
+
displayName: string;
|
|
13
|
+
url: string;
|
|
14
|
+
id: string;
|
|
15
|
+
uniqueName: string;
|
|
16
|
+
imageUrl: string;
|
|
17
|
+
descriptor: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Branch {
|
|
20
|
+
name: string;
|
|
21
|
+
aheadCount: number;
|
|
22
|
+
behindCount: number;
|
|
23
|
+
isBaseVersion: boolean;
|
|
24
|
+
commits: Commit[];
|
|
25
|
+
}
|
|
26
|
+
interface TagCommitObject {
|
|
27
|
+
objectId: string;
|
|
28
|
+
objectType: string;
|
|
29
|
+
}
|
|
30
|
+
export interface TagCommit {
|
|
31
|
+
name: string;
|
|
32
|
+
objectId: string;
|
|
33
|
+
taggedObject: TagCommitObject;
|
|
34
|
+
taggedBy: CommitAuthor;
|
|
35
|
+
message: string;
|
|
36
|
+
url: string;
|
|
37
|
+
}
|
|
38
|
+
export interface Tag {
|
|
39
|
+
name: string;
|
|
40
|
+
objectId: string;
|
|
41
|
+
url: string;
|
|
42
|
+
creator: Creator;
|
|
43
|
+
commit: TagCommit;
|
|
44
|
+
}
|
|
45
|
+
export interface Repository {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
url: string;
|
|
49
|
+
project: Project;
|
|
50
|
+
defaultBranch: string;
|
|
51
|
+
size: number;
|
|
52
|
+
remoteUrl: string;
|
|
53
|
+
sshUrl: string;
|
|
54
|
+
webUrl: string;
|
|
55
|
+
isDisabled: boolean;
|
|
56
|
+
branches: Branch[];
|
|
57
|
+
tags: Tag[];
|
|
58
|
+
}
|
|
59
|
+
export interface PullRequestThreadComment {
|
|
60
|
+
id: number;
|
|
61
|
+
parentCommentId: number;
|
|
62
|
+
content: string;
|
|
63
|
+
publishedDate: string;
|
|
64
|
+
lastUpdatedDate: string;
|
|
65
|
+
lastContentUpdatedDate: string;
|
|
66
|
+
commentType: string;
|
|
67
|
+
author: Creator;
|
|
68
|
+
}
|
|
69
|
+
export interface PullRequestThread {
|
|
70
|
+
pullRequestThreadContext?: string;
|
|
71
|
+
id: number;
|
|
72
|
+
publishedDate: string;
|
|
73
|
+
lastUpdatedDate: string;
|
|
74
|
+
status: string;
|
|
75
|
+
threadContext?: string;
|
|
76
|
+
comments: PullRequestThreadComment[];
|
|
77
|
+
}
|
|
78
|
+
interface MergeSourceCommit {
|
|
79
|
+
commitId: string;
|
|
80
|
+
url: string;
|
|
81
|
+
}
|
|
82
|
+
export interface PullRequestRepository {
|
|
83
|
+
id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
url: string;
|
|
86
|
+
project: Project;
|
|
87
|
+
}
|
|
88
|
+
export interface PullRequestCommitChangeCounts {
|
|
89
|
+
Edit?: number;
|
|
90
|
+
Add?: number;
|
|
91
|
+
Delete?: number;
|
|
92
|
+
}
|
|
93
|
+
export interface PullRequestCommit {
|
|
94
|
+
commitId: string;
|
|
95
|
+
author: CommitAuthor;
|
|
96
|
+
committer: CommitAuthor;
|
|
97
|
+
comment: string;
|
|
98
|
+
url: string;
|
|
99
|
+
changeCounts: PullRequestCommitChangeCounts;
|
|
100
|
+
}
|
|
101
|
+
export interface PullRequestReviewer {
|
|
102
|
+
reviewerUrl: string;
|
|
103
|
+
vote: number;
|
|
104
|
+
hasDeclined: boolean;
|
|
105
|
+
isFlagged: boolean;
|
|
106
|
+
displayName: string;
|
|
107
|
+
url: string;
|
|
108
|
+
id: string;
|
|
109
|
+
uniqueName: string;
|
|
110
|
+
imageUrl: string;
|
|
111
|
+
}
|
|
112
|
+
export interface PullRequest {
|
|
113
|
+
pullRequestId: number;
|
|
114
|
+
codeReviewId: number;
|
|
115
|
+
status: string;
|
|
116
|
+
createdBy: Creator;
|
|
117
|
+
creationDate: string;
|
|
118
|
+
closedDate?: string;
|
|
119
|
+
title: string;
|
|
120
|
+
description: string;
|
|
121
|
+
sourceRefName: string;
|
|
122
|
+
targetRefName: string;
|
|
123
|
+
mergeStatus: string;
|
|
124
|
+
isDraft: boolean;
|
|
125
|
+
mergeId: string;
|
|
126
|
+
lastMergeSourceCommit: MergeSourceCommit;
|
|
127
|
+
lastMergeCommit: MergeSourceCommit;
|
|
128
|
+
reviewers: [PullRequestReviewer];
|
|
129
|
+
url: string;
|
|
130
|
+
supportsIterations: boolean;
|
|
131
|
+
repository: PullRequestRepository;
|
|
132
|
+
commits: PullRequestCommit[];
|
|
133
|
+
threads: PullRequestThread[];
|
|
134
|
+
}
|
|
135
|
+
interface CommitAuthor {
|
|
136
|
+
name: string;
|
|
137
|
+
email: string;
|
|
138
|
+
date: string;
|
|
139
|
+
}
|
|
140
|
+
interface CommitChange {
|
|
141
|
+
Add: number;
|
|
142
|
+
Edit: number;
|
|
143
|
+
Delete: number;
|
|
144
|
+
}
|
|
145
|
+
export interface Commit {
|
|
146
|
+
commitId: string;
|
|
147
|
+
author: CommitAuthor;
|
|
148
|
+
committer: CommitAuthor;
|
|
149
|
+
comment: string;
|
|
150
|
+
changeCounts: CommitChange;
|
|
151
|
+
url: string;
|
|
152
|
+
remoteUrl: string;
|
|
153
|
+
}
|
|
154
|
+
interface Href {
|
|
155
|
+
href: string;
|
|
156
|
+
}
|
|
157
|
+
interface UserLink {
|
|
158
|
+
self: Href;
|
|
159
|
+
memberships: Href;
|
|
160
|
+
membershipState: Href;
|
|
161
|
+
storageKey: Href;
|
|
162
|
+
avatar: Href;
|
|
163
|
+
}
|
|
164
|
+
export interface User {
|
|
165
|
+
subjectKind: string;
|
|
166
|
+
domain: string;
|
|
167
|
+
principalName: string;
|
|
168
|
+
mailAddress: string;
|
|
169
|
+
origin: string;
|
|
170
|
+
originId: string;
|
|
171
|
+
displayName: string;
|
|
172
|
+
url: string;
|
|
173
|
+
descriptor: string;
|
|
174
|
+
_links: UserLink;
|
|
175
|
+
}
|
|
176
|
+
export interface OrgType {
|
|
177
|
+
category: OrgTypeCategory;
|
|
178
|
+
detail: string;
|
|
179
|
+
}
|
|
180
|
+
export declare enum OrgTypeCategory {
|
|
181
|
+
Organization = "Organization",
|
|
182
|
+
Workspace = "Workspace",
|
|
183
|
+
Group = "Group",
|
|
184
|
+
Custom = "Custom"
|
|
185
|
+
}
|
|
186
|
+
export interface PullRequestState {
|
|
187
|
+
category: PullRequestStateCategory;
|
|
188
|
+
detail: string;
|
|
189
|
+
}
|
|
190
|
+
export declare enum PullRequestStateCategory {
|
|
191
|
+
Closed = "Closed",
|
|
192
|
+
Merged = "Merged",
|
|
193
|
+
Open = "Open",
|
|
194
|
+
Custom = "Custom"
|
|
195
|
+
}
|
|
196
|
+
export interface PullRequestReviewState {
|
|
197
|
+
category: PullRequestReviewStateCategory;
|
|
198
|
+
detail: string;
|
|
199
|
+
}
|
|
200
|
+
export declare enum PullRequestReviewStateCategory {
|
|
201
|
+
Approved = "Approved",
|
|
202
|
+
Commented = "Commented",
|
|
203
|
+
ChangesRequested = "ChangesRequested",
|
|
204
|
+
Dismissed = "Dismissed",
|
|
205
|
+
Custom = "Custom"
|
|
206
|
+
}
|
|
207
|
+
export interface UserType {
|
|
208
|
+
category: UserTypeCategory;
|
|
209
|
+
detail: string;
|
|
210
|
+
}
|
|
211
|
+
export declare enum UserTypeCategory {
|
|
212
|
+
Bot = "Bot",
|
|
213
|
+
Organization = "Organization",
|
|
214
|
+
User = "User",
|
|
215
|
+
Custom = "Custom"
|
|
216
|
+
}
|
|
217
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserTypeCategory = exports.PullRequestReviewStateCategory = exports.PullRequestStateCategory = exports.OrgTypeCategory = void 0;
|
|
4
|
+
var OrgTypeCategory;
|
|
5
|
+
(function (OrgTypeCategory) {
|
|
6
|
+
OrgTypeCategory["Organization"] = "Organization";
|
|
7
|
+
OrgTypeCategory["Workspace"] = "Workspace";
|
|
8
|
+
OrgTypeCategory["Group"] = "Group";
|
|
9
|
+
OrgTypeCategory["Custom"] = "Custom";
|
|
10
|
+
})(OrgTypeCategory = exports.OrgTypeCategory || (exports.OrgTypeCategory = {}));
|
|
11
|
+
var PullRequestStateCategory;
|
|
12
|
+
(function (PullRequestStateCategory) {
|
|
13
|
+
PullRequestStateCategory["Closed"] = "Closed";
|
|
14
|
+
PullRequestStateCategory["Merged"] = "Merged";
|
|
15
|
+
PullRequestStateCategory["Open"] = "Open";
|
|
16
|
+
PullRequestStateCategory["Custom"] = "Custom";
|
|
17
|
+
})(PullRequestStateCategory = exports.PullRequestStateCategory || (exports.PullRequestStateCategory = {}));
|
|
18
|
+
var PullRequestReviewStateCategory;
|
|
19
|
+
(function (PullRequestReviewStateCategory) {
|
|
20
|
+
PullRequestReviewStateCategory["Approved"] = "Approved";
|
|
21
|
+
PullRequestReviewStateCategory["Commented"] = "Commented";
|
|
22
|
+
PullRequestReviewStateCategory["ChangesRequested"] = "ChangesRequested";
|
|
23
|
+
PullRequestReviewStateCategory["Dismissed"] = "Dismissed";
|
|
24
|
+
PullRequestReviewStateCategory["Custom"] = "Custom";
|
|
25
|
+
})(PullRequestReviewStateCategory = exports.PullRequestReviewStateCategory || (exports.PullRequestReviewStateCategory = {}));
|
|
26
|
+
var UserTypeCategory;
|
|
27
|
+
(function (UserTypeCategory) {
|
|
28
|
+
UserTypeCategory["Bot"] = "Bot";
|
|
29
|
+
UserTypeCategory["Organization"] = "Organization";
|
|
30
|
+
UserTypeCategory["User"] = "User";
|
|
31
|
+
UserTypeCategory["Custom"] = "Custom";
|
|
32
|
+
})(UserTypeCategory = exports.UserTypeCategory || (exports.UserTypeCategory = {}));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
|
|
3
|
+
import { AzureReposConverter } from './common';
|
|
4
|
+
export declare class PullRequests extends AzureReposConverter {
|
|
5
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PullRequests = void 0;
|
|
4
|
+
const lib_1 = require("faros-feeds-sdk/lib");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
class PullRequests extends common_1.AzureReposConverter {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.destinationModels = [
|
|
10
|
+
'vcs_PullRequest',
|
|
11
|
+
'vcs_PullRequestReview',
|
|
12
|
+
'vcs_PullRequestComment',
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
async convert(record, ctx) {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
const source = this.streamName.source;
|
|
18
|
+
const pullRequestItem = record.record.data;
|
|
19
|
+
const organizationName = this.getOrganizationFromUrl(pullRequestItem.repository.url);
|
|
20
|
+
const organization = { uid: organizationName, source };
|
|
21
|
+
const repository = { name: pullRequestItem.repository.name, organization };
|
|
22
|
+
const pullRequest = { number: pullRequestItem.pullRequestId, repository };
|
|
23
|
+
const res = [];
|
|
24
|
+
const diffStats = { linesAdded: 0, linesDeleted: 0, filesChanged: 0 };
|
|
25
|
+
for (const commit of pullRequestItem.commits) {
|
|
26
|
+
diffStats.linesAdded += (_a = commit.changeCounts.Add) !== null && _a !== void 0 ? _a : 0;
|
|
27
|
+
diffStats.linesDeleted += (_b = commit.changeCounts.Delete) !== null && _b !== void 0 ? _b : 0;
|
|
28
|
+
diffStats.filesChanged += (_c = commit.changeCounts.Edit) !== null && _c !== void 0 ? _c : 0;
|
|
29
|
+
}
|
|
30
|
+
for (const thread of pullRequestItem.threads) {
|
|
31
|
+
for (const comment of thread.comments) {
|
|
32
|
+
res.push({
|
|
33
|
+
model: 'vcs_PullRequestComment',
|
|
34
|
+
record: {
|
|
35
|
+
number: comment.id,
|
|
36
|
+
comment: comment.content,
|
|
37
|
+
createdAt: lib_1.Utils.toDate(comment.publishedDate),
|
|
38
|
+
updatedAt: lib_1.Utils.toDate(comment.lastUpdatedDate),
|
|
39
|
+
author: { uid: comment.author.uniqueName, source },
|
|
40
|
+
pullRequest,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
res.push({
|
|
46
|
+
model: 'vcs_PullRequest',
|
|
47
|
+
record: {
|
|
48
|
+
number: pullRequestItem.pullRequestId,
|
|
49
|
+
title: pullRequestItem.title,
|
|
50
|
+
state: this.convertPullRequestState(pullRequestItem.status),
|
|
51
|
+
htmlUrl: pullRequestItem.url,
|
|
52
|
+
createdAt: lib_1.Utils.toDate(pullRequestItem.creationDate),
|
|
53
|
+
updatedAt: lib_1.Utils.toDate(pullRequestItem.creationDate),
|
|
54
|
+
mergedAt: lib_1.Utils.toDate(pullRequestItem.closedDate),
|
|
55
|
+
commitCount: pullRequestItem.commits.length,
|
|
56
|
+
commentCount: pullRequestItem.threads.length,
|
|
57
|
+
diffStats,
|
|
58
|
+
author: { uid: pullRequestItem.createdBy.uniqueName, source },
|
|
59
|
+
mergeCommit: {
|
|
60
|
+
sha: pullRequestItem.lastMergeCommit.commitId,
|
|
61
|
+
repository,
|
|
62
|
+
},
|
|
63
|
+
repository,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
for (const reviewer of pullRequestItem.reviewers) {
|
|
67
|
+
res.push({
|
|
68
|
+
model: 'vcs_PullRequestReview',
|
|
69
|
+
record: {
|
|
70
|
+
number: this.convertStringToNumber(reviewer.id),
|
|
71
|
+
htmlUrl: reviewer.url,
|
|
72
|
+
state: this.convertPullRequestReviewState(reviewer.vote),
|
|
73
|
+
submittedAt: null,
|
|
74
|
+
reviewer: { uid: reviewer.uniqueName, source },
|
|
75
|
+
pullRequest,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return res;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.PullRequests = PullRequests;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
|
|
3
|
+
import { AzureReposConverter } from './common';
|
|
4
|
+
export declare class Repositories extends AzureReposConverter {
|
|
5
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
+
private seenOrganizations;
|
|
7
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Repositories = void 0;
|
|
4
|
+
const lib_1 = require("faros-feeds-sdk/lib");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
const models_1 = require("./models");
|
|
7
|
+
class Repositories extends common_1.AzureReposConverter {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.destinationModels = [
|
|
11
|
+
'vcs_Branch',
|
|
12
|
+
'vcs_Commit',
|
|
13
|
+
'vcs_BranchCommitAssociation',
|
|
14
|
+
'vcs_Organization',
|
|
15
|
+
'vcs_Repository',
|
|
16
|
+
'vcs_Tag',
|
|
17
|
+
];
|
|
18
|
+
this.seenOrganizations = new Set();
|
|
19
|
+
}
|
|
20
|
+
async convert(record, ctx) {
|
|
21
|
+
const source = this.streamName.source;
|
|
22
|
+
const repositoryItem = record.record.data;
|
|
23
|
+
const res = [];
|
|
24
|
+
const organizationName = this.getOrganizationFromUrl(repositoryItem.url);
|
|
25
|
+
const organization = { uid: organizationName, source };
|
|
26
|
+
const repository = { name: repositoryItem.name, organization };
|
|
27
|
+
if (!this.seenOrganizations.has(organizationName)) {
|
|
28
|
+
this.seenOrganizations.add(organizationName);
|
|
29
|
+
res.push({
|
|
30
|
+
model: 'vcs_Organization',
|
|
31
|
+
record: {
|
|
32
|
+
uid: organizationName,
|
|
33
|
+
name: organizationName,
|
|
34
|
+
htmlUrl: `https://dev.azure.com/${organizationName}`,
|
|
35
|
+
type: { category: models_1.OrgTypeCategory.Organization, organizationName },
|
|
36
|
+
description: organizationName,
|
|
37
|
+
createdAt: null,
|
|
38
|
+
source,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
let createdAt = null;
|
|
43
|
+
for (const branch of repositoryItem.branches) {
|
|
44
|
+
if (createdAt == null &&
|
|
45
|
+
repositoryItem.defaultBranch.endsWith(branch.name)) {
|
|
46
|
+
createdAt = lib_1.Utils.toDate(branch.commits[branch.commits.length - 1].committer.date);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
res.push({
|
|
51
|
+
model: 'vcs_Repository',
|
|
52
|
+
record: {
|
|
53
|
+
name: repositoryItem.name,
|
|
54
|
+
fullName: repositoryItem.name,
|
|
55
|
+
description: repositoryItem.name,
|
|
56
|
+
private: repositoryItem.project.visibility == 'private',
|
|
57
|
+
language: null,
|
|
58
|
+
size: repositoryItem.size,
|
|
59
|
+
mainBranch: repositoryItem.defaultBranch,
|
|
60
|
+
htmlUrl: repositoryItem.webUrl,
|
|
61
|
+
createdAt,
|
|
62
|
+
updatedAt: null,
|
|
63
|
+
organization,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
for (const branch of repositoryItem.branches) {
|
|
67
|
+
res.push({
|
|
68
|
+
model: 'vcs_Branch',
|
|
69
|
+
record: {
|
|
70
|
+
name: branch.name,
|
|
71
|
+
repository,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
for (const commit of branch.commits) {
|
|
75
|
+
res.push({
|
|
76
|
+
model: 'vcs_Commit',
|
|
77
|
+
record: {
|
|
78
|
+
sha: commit.commitId,
|
|
79
|
+
message: commit.comment,
|
|
80
|
+
htmlUrl: commit.remoteUrl,
|
|
81
|
+
createdAt: lib_1.Utils.toDate(commit.committer.date),
|
|
82
|
+
author: { uid: commit.author.email, source },
|
|
83
|
+
repository,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
res.push({
|
|
87
|
+
model: 'vcs_BranchCommitAssociation',
|
|
88
|
+
record: {
|
|
89
|
+
commit: { sha: commit.commitId, repository },
|
|
90
|
+
branch: { name: branch.name, repository },
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
for (const tag of repositoryItem.tags) {
|
|
96
|
+
res.push({
|
|
97
|
+
model: 'vcs_Tag',
|
|
98
|
+
record: {
|
|
99
|
+
name: tag.name,
|
|
100
|
+
message: tag.commit.message,
|
|
101
|
+
commit: { sha: tag.commit.taggedObject.objectId, repository },
|
|
102
|
+
repository,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return res;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.Repositories = Repositories;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
|
|
3
|
+
import { AzureReposConverter } from './common';
|
|
4
|
+
export declare class Users extends AzureReposConverter {
|
|
5
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Users = void 0;
|
|
4
|
+
const common_1 = require("./common");
|
|
5
|
+
const models_1 = require("./models");
|
|
6
|
+
class Users extends common_1.AzureReposConverter {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.destinationModels = [
|
|
10
|
+
'vcs_Membership',
|
|
11
|
+
'vcs_User',
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
async convert(record, ctx) {
|
|
15
|
+
const source = this.streamName.source;
|
|
16
|
+
const userItem = record.record.data;
|
|
17
|
+
const res = [];
|
|
18
|
+
const organizationName = this.getOrganizationFromUrl(userItem._links.self.href);
|
|
19
|
+
const organization = { uid: organizationName, source };
|
|
20
|
+
const type = {
|
|
21
|
+
category: models_1.UserTypeCategory.User,
|
|
22
|
+
detail: userItem.subjectKind,
|
|
23
|
+
};
|
|
24
|
+
res.push({
|
|
25
|
+
model: 'vcs_Membership',
|
|
26
|
+
record: {
|
|
27
|
+
organization,
|
|
28
|
+
user: { uid: userItem.principalName, source },
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
res.push({
|
|
32
|
+
model: 'vcs_User',
|
|
33
|
+
record: {
|
|
34
|
+
uid: userItem.principalName,
|
|
35
|
+
name: userItem.displayName,
|
|
36
|
+
type,
|
|
37
|
+
htmlUrl: userItem.url,
|
|
38
|
+
source,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
return res;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.Users = Users;
|
|
@@ -54,7 +54,11 @@ class Pipelines extends common_1.BitbucketConverter {
|
|
|
54
54
|
model: 'cicd_BuildCommitAssociation',
|
|
55
55
|
record: {
|
|
56
56
|
build: { uid: pipeline.uuid, pipeline: pipelineKey },
|
|
57
|
-
commit: {
|
|
57
|
+
commit: {
|
|
58
|
+
repository: projectKey,
|
|
59
|
+
sha: pipeline.target.commit.hash,
|
|
60
|
+
uid: pipeline.target.commit.hash,
|
|
61
|
+
},
|
|
58
62
|
},
|
|
59
63
|
});
|
|
60
64
|
}
|
|
@@ -77,7 +77,7 @@ class Builds extends common_1.BuildkiteConverter {
|
|
|
77
77
|
model: 'cicd_BuildCommitAssociation',
|
|
78
78
|
record: {
|
|
79
79
|
build: buildKey,
|
|
80
|
-
commit: { repository: repoKey, sha: build.commit },
|
|
80
|
+
commit: { repository: repoKey, sha: build.commit, uid: build.commit },
|
|
81
81
|
},
|
|
82
82
|
});
|
|
83
83
|
}
|
|
@@ -13,11 +13,16 @@ interface RepositoryKey {
|
|
|
13
13
|
uid: string;
|
|
14
14
|
organization: OrgKey;
|
|
15
15
|
}
|
|
16
|
+
interface BuildKey {
|
|
17
|
+
uid: string;
|
|
18
|
+
pipeline: Omit<RepositoryKey, 'name'>;
|
|
19
|
+
}
|
|
16
20
|
/** Common functions shares across GitLab converters */
|
|
17
21
|
export declare class GitlabCommon {
|
|
18
22
|
static readonly MAX_DESCRIPTION_LENGTH = 1000;
|
|
19
23
|
static tms_ProjectBoard_with_TaskBoard(projectKey: ProjectKey, name: string, description: string | null, createdAt: string | null | undefined, updatedAt: string | null | undefined): DestinationRecord[];
|
|
20
24
|
static parseRepositoryKey(webUrl: string | undefined, source: string, startIndex?: number): undefined | RepositoryKey;
|
|
25
|
+
static createBuildKey(pipelineId: any, repository: RepositoryKey): BuildKey;
|
|
21
26
|
static convertBuildStatus(status?: string): CategoryRef;
|
|
22
27
|
}
|
|
23
28
|
/** GitLab converter base */
|
|
@@ -48,6 +48,15 @@ class GitlabCommon {
|
|
|
48
48
|
organization: { uid: organization === null || organization === void 0 ? void 0 : organization.toLowerCase(), source },
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
+
static createBuildKey(pipelineId, repository) {
|
|
52
|
+
return {
|
|
53
|
+
uid: String(pipelineId),
|
|
54
|
+
pipeline: {
|
|
55
|
+
organization: repository.organization,
|
|
56
|
+
uid: repository.name,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
51
60
|
// GitLab defined status for:
|
|
52
61
|
// >> pipelines (aka builds): created, waiting_for_resource, preparing, pending,
|
|
53
62
|
// running, success, failed, canceled, skipped, manual, scheduled
|
|
@@ -10,7 +10,10 @@ class Assignees extends common_1.GitHubConverter {
|
|
|
10
10
|
async convert(record, ctx) {
|
|
11
11
|
const source = this.streamName.source;
|
|
12
12
|
const user = record.record.data;
|
|
13
|
-
|
|
13
|
+
const res = common_1.GitHubCommon.tms_User(user, source);
|
|
14
|
+
if (res)
|
|
15
|
+
return [res];
|
|
16
|
+
return [];
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
19
|
exports.Assignees = Assignees;
|
|
@@ -11,7 +11,7 @@ export declare class GitHubCommon {
|
|
|
11
11
|
};
|
|
12
12
|
static vcs_User(user: Dictionary<any>, source: string): DestinationRecord;
|
|
13
13
|
static vcs_Membership(userUid: string, org: string, source: string): DestinationRecord;
|
|
14
|
-
static tms_User(user: Dictionary<any
|
|
14
|
+
static tms_User(user: Dictionary<any> | undefined, source: string): DestinationRecord | undefined;
|
|
15
15
|
static tms_ProjectBoard_with_TaskBoard(projectKey: ProjectKey, name: string, description: string | null, createdAt: string | null | undefined, updatedAt: string | null | undefined): DestinationRecord[];
|
|
16
16
|
static parseRepositoryKey(repository: string, source: string): undefined | RepositoryKey;
|
|
17
17
|
static parsePRnumber(pull_request_url: string): number;
|