airbyte-faros-destination 0.10.29 → 0.10.31
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/bitbucket/commits.d.ts +1 -2
- package/lib/converters/bitbucket/commits.js +7 -18
- package/lib/converters/bitbucket/commits.js.map +1 -1
- package/lib/converters/bitbucket/common.d.ts +8 -8
- package/lib/converters/bitbucket/common.js +4 -99
- package/lib/converters/bitbucket/common.js.map +1 -1
- package/lib/converters/bitbucket/{pull_request_activities.d.ts → pull_requests_with_activities.d.ts} +8 -1
- package/lib/converters/bitbucket/pull_requests_with_activities.js +221 -0
- package/lib/converters/bitbucket/pull_requests_with_activities.js.map +1 -0
- package/lib/converters/bitbucket/tags.d.ts +7 -0
- package/lib/converters/bitbucket/tags.js +37 -0
- package/lib/converters/bitbucket/tags.js.map +1 -0
- package/lib/converters/bitbucket/workspace_users.d.ts +1 -2
- package/lib/converters/bitbucket/workspace_users.js +32 -6
- package/lib/converters/bitbucket/workspace_users.js.map +1 -1
- package/lib/converters/common/vcs.d.ts +14 -0
- package/lib/converters/common/vcs.js +35 -1
- package/lib/converters/common/vcs.js.map +1 -1
- package/lib/converters/github/faros_pull_requests.d.ts +2 -4
- package/lib/converters/github/faros_pull_requests.js +4 -29
- package/lib/converters/github/faros_pull_requests.js.map +1 -1
- package/lib/destination.js +7 -2
- package/lib/destination.js.map +1 -1
- package/lib/sync.d.ts +2 -0
- package/lib/sync.js +2 -0
- package/lib/sync.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -3
- package/lib/converters/bitbucket/issues.d.ts +0 -12
- package/lib/converters/bitbucket/issues.js +0 -129
- package/lib/converters/bitbucket/issues.js.map +0 -1
- package/lib/converters/bitbucket/pull_request_activities.js +0 -113
- package/lib/converters/bitbucket/pull_request_activities.js.map +0 -1
- package/lib/converters/bitbucket/pull_requests.d.ts +0 -10
- package/lib/converters/bitbucket/pull_requests.js +0 -98
- package/lib/converters/bitbucket/pull_requests.js.map +0 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
-
import { DestinationModel, DestinationRecord
|
|
2
|
+
import { DestinationModel, DestinationRecord } from '../converter';
|
|
3
3
|
import { BitbucketConverter } from './common';
|
|
4
4
|
export declare class Commits extends BitbucketConverter {
|
|
5
5
|
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
6
|
id(record: AirbyteRecord): any;
|
|
7
7
|
convert(record: AirbyteRecord): Promise<ReadonlyArray<DestinationRecord>>;
|
|
8
|
-
onProcessingComplete(ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
9
8
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Commits = void 0;
|
|
4
4
|
const faros_js_client_1 = require("faros-js-client");
|
|
5
|
-
const lodash_1 = require("lodash");
|
|
6
5
|
const common_1 = require("./common");
|
|
7
6
|
class Commits extends common_1.BitbucketConverter {
|
|
8
7
|
constructor() {
|
|
@@ -14,7 +13,7 @@ class Commits extends common_1.BitbucketConverter {
|
|
|
14
13
|
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.hash;
|
|
15
14
|
}
|
|
16
15
|
async convert(record) {
|
|
17
|
-
var _a, _b
|
|
16
|
+
var _a, _b;
|
|
18
17
|
const source = this.streamName.source;
|
|
19
18
|
const commit = record.record.data;
|
|
20
19
|
const res = [];
|
|
@@ -22,33 +21,23 @@ class Commits extends common_1.BitbucketConverter {
|
|
|
22
21
|
if (!workspace || !repo) {
|
|
23
22
|
return res;
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
if ((_b = (_a = commit === null || commit === void 0 ? void 0 : commit.author) === null || _a === void 0 ? void 0 : _a.user) === null || _b === void 0 ? void 0 : _b.accountId) {
|
|
27
|
-
const commitUser = commit.author.user;
|
|
28
|
-
this.collectUser(commitUser, workspace);
|
|
29
|
-
author = { uid: commitUser.accountId, source };
|
|
30
|
-
}
|
|
24
|
+
const commitUser = (_a = commit === null || commit === void 0 ? void 0 : commit.author) === null || _a === void 0 ? void 0 : _a.user;
|
|
31
25
|
res.push({
|
|
32
26
|
model: 'vcs_Commit',
|
|
33
27
|
record: {
|
|
34
28
|
sha: commit.hash,
|
|
35
29
|
uid: commit.hash,
|
|
36
30
|
message: commit.message,
|
|
37
|
-
htmlUrl: (
|
|
31
|
+
htmlUrl: (_b = commit.links) === null || _b === void 0 ? void 0 : _b.htmlUrl,
|
|
38
32
|
createdAt: faros_js_client_1.Utils.toDate(commit.date),
|
|
39
|
-
author
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
name: (0, lodash_1.toLower)(repo),
|
|
44
|
-
},
|
|
33
|
+
author: (commitUser === null || commitUser === void 0 ? void 0 : commitUser.accountId)
|
|
34
|
+
? { uid: commitUser.accountId, source }
|
|
35
|
+
: null,
|
|
36
|
+
repository: common_1.BitbucketCommon.vcs_Repository(workspace, repo, source),
|
|
45
37
|
},
|
|
46
38
|
});
|
|
47
39
|
return res;
|
|
48
40
|
}
|
|
49
|
-
async onProcessingComplete(ctx) {
|
|
50
|
-
return this.convertUsers();
|
|
51
|
-
}
|
|
52
41
|
}
|
|
53
42
|
exports.Commits = Commits;
|
|
54
43
|
//# sourceMappingURL=commits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commits.js","sourceRoot":"","sources":["../../../src/converters/bitbucket/commits.ts"],"names":[],"mappings":";;;AAEA,qDAAsC;
|
|
1
|
+
{"version":3,"file":"commits.js","sourceRoot":"","sources":["../../../src/converters/bitbucket/commits.ts"],"names":[],"mappings":";;;AAEA,qDAAsC;AAGtC,qCAA6D;AAE7D,MAAa,OAAQ,SAAQ,2BAAkB;IAA/C;;QACW,sBAAiB,GAAoC,CAAC,Y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AC,CAAC;QAEH,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAvCD,0BAuCC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
2
|
import { User } from 'faros-airbyte-common/bitbucket';
|
|
3
|
-
import { Converter,
|
|
3
|
+
import { Converter, StreamContext } from '../converter';
|
|
4
4
|
interface BitbucketConfig {
|
|
5
5
|
application_mapping?: ApplicationMapping;
|
|
6
6
|
max_description_length?: number;
|
|
@@ -20,15 +20,18 @@ export declare enum UserTypeCategory {
|
|
|
20
20
|
CUSTOM = "Custom"
|
|
21
21
|
}
|
|
22
22
|
export type PartialUser = Partial<User>;
|
|
23
|
-
export interface
|
|
23
|
+
export interface RepositoryRecord {
|
|
24
24
|
uid: string;
|
|
25
|
-
|
|
25
|
+
name: string;
|
|
26
|
+
organization: {
|
|
27
|
+
uid: string;
|
|
28
|
+
source: string;
|
|
29
|
+
};
|
|
26
30
|
}
|
|
27
31
|
/** Common functions shares across Bitbucket converters */
|
|
28
32
|
export declare class BitbucketCommon {
|
|
29
33
|
static MAX_DESCRIPTION_LENGTH: number;
|
|
30
|
-
static
|
|
31
|
-
static tms_ProjectBoard_with_TaskBoard(projectKey: ProjectKey, name: string, description: string | null, createdAt: string | null | undefined, updatedAt: string | null | undefined): DestinationRecord[];
|
|
34
|
+
static vcs_Repository(workspace: string, repo: string, source: string): RepositoryRecord;
|
|
32
35
|
}
|
|
33
36
|
/** Bitbucket converter base */
|
|
34
37
|
export declare abstract class BitbucketConverter extends Converter {
|
|
@@ -39,8 +42,5 @@ export declare abstract class BitbucketConverter extends Converter {
|
|
|
39
42
|
protected bitbucketConfig(ctx: StreamContext): BitbucketConfig;
|
|
40
43
|
protected applicationMapping(ctx: StreamContext): ApplicationMapping;
|
|
41
44
|
protected maxDescriptionLength(ctx: StreamContext): number;
|
|
42
|
-
protected collectUser(user: PartialUser, workspace: string): void;
|
|
43
|
-
protected convertUsers(): DestinationRecord[];
|
|
44
|
-
private getFinalUser;
|
|
45
45
|
}
|
|
46
46
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BitbucketConverter = exports.BitbucketCommon = exports.UserTypeCategory = void 0;
|
|
4
|
-
const faros_js_client_1 = require("faros-js-client");
|
|
5
4
|
const lodash_1 = require("lodash");
|
|
6
5
|
const converter_1 = require("../converter");
|
|
7
6
|
var UserTypeCategory;
|
|
@@ -13,53 +12,13 @@ var UserTypeCategory;
|
|
|
13
12
|
})(UserTypeCategory || (exports.UserTypeCategory = UserTypeCategory = {}));
|
|
14
13
|
/** Common functions shares across Bitbucket converters */
|
|
15
14
|
class BitbucketCommon {
|
|
16
|
-
static
|
|
17
|
-
var _a;
|
|
18
|
-
if (!user.accountId)
|
|
19
|
-
return undefined;
|
|
20
|
-
const userType = user.type === 'user'
|
|
21
|
-
? { category: UserTypeCategory.USER, detail: 'user' }
|
|
22
|
-
: { category: UserTypeCategory.CUSTOM, detail: user.type };
|
|
15
|
+
static vcs_Repository(workspace, repo, source) {
|
|
23
16
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
name: user.displayName,
|
|
28
|
-
email: user.emailAddress,
|
|
29
|
-
type: userType,
|
|
30
|
-
htmlUrl: (_a = user.links) === null || _a === void 0 ? void 0 : _a.htmlUrl,
|
|
31
|
-
source,
|
|
32
|
-
},
|
|
17
|
+
name: (0, lodash_1.toLower)(repo),
|
|
18
|
+
uid: (0, lodash_1.toLower)(repo),
|
|
19
|
+
organization: { uid: (0, lodash_1.toLower)(workspace), source },
|
|
33
20
|
};
|
|
34
21
|
}
|
|
35
|
-
static tms_ProjectBoard_with_TaskBoard(projectKey, name, description, createdAt, updatedAt) {
|
|
36
|
-
return [
|
|
37
|
-
{
|
|
38
|
-
model: 'tms_Project',
|
|
39
|
-
record: {
|
|
40
|
-
...projectKey,
|
|
41
|
-
name: name,
|
|
42
|
-
description: faros_js_client_1.Utils.cleanAndTruncate(description, BitbucketCommon.MAX_DESCRIPTION_LENGTH),
|
|
43
|
-
createdAt: faros_js_client_1.Utils.toDate(createdAt),
|
|
44
|
-
updatedAt: faros_js_client_1.Utils.toDate(updatedAt),
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
model: 'tms_TaskBoard',
|
|
49
|
-
record: {
|
|
50
|
-
...projectKey,
|
|
51
|
-
name,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
model: 'tms_TaskBoardProjectRelationship',
|
|
56
|
-
record: {
|
|
57
|
-
board: projectKey,
|
|
58
|
-
project: projectKey,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
];
|
|
62
|
-
}
|
|
63
22
|
}
|
|
64
23
|
exports.BitbucketCommon = BitbucketCommon;
|
|
65
24
|
// max length for free-form description text field
|
|
@@ -88,60 +47,6 @@ class BitbucketConverter extends converter_1.Converter {
|
|
|
88
47
|
var _a, _b;
|
|
89
48
|
return ((_b = (_a = this.bitbucketConfig(ctx)) === null || _a === void 0 ? void 0 : _a.max_description_length) !== null && _b !== void 0 ? _b : BitbucketCommon.MAX_DESCRIPTION_LENGTH);
|
|
90
49
|
}
|
|
91
|
-
collectUser(user, workspace) {
|
|
92
|
-
var _a;
|
|
93
|
-
if (!(user === null || user === void 0 ? void 0 : user.accountId))
|
|
94
|
-
return;
|
|
95
|
-
if (!this.collectedUsers.has(user.accountId)) {
|
|
96
|
-
this.collectedUsers.set(user.accountId, []);
|
|
97
|
-
}
|
|
98
|
-
(_a = this.collectedUsers.get(user.accountId)) === null || _a === void 0 ? void 0 : _a.push({
|
|
99
|
-
...user,
|
|
100
|
-
workspace,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
convertUsers() {
|
|
104
|
-
const records = [];
|
|
105
|
-
const source = this.streamName.source;
|
|
106
|
-
for (const [accountId, users] of this.collectedUsers.entries()) {
|
|
107
|
-
const emails = new Set(users.map((user) => user.emailAddress).filter((email) => !!email));
|
|
108
|
-
for (const email of emails) {
|
|
109
|
-
records.push({
|
|
110
|
-
model: 'vcs_UserEmail',
|
|
111
|
-
record: {
|
|
112
|
-
user: { uid: accountId, source },
|
|
113
|
-
email,
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
const workspaces = new Set(users.map((user) => user.workspace).filter((org) => !(0, lodash_1.isEmpty)(org)));
|
|
118
|
-
for (const workspace of workspaces) {
|
|
119
|
-
records.push({
|
|
120
|
-
model: 'vcs_Membership',
|
|
121
|
-
record: {
|
|
122
|
-
user: { uid: accountId, source },
|
|
123
|
-
organization: { uid: (0, lodash_1.toLower)(workspace), source },
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
const finalUser = this.getFinalUser(users);
|
|
128
|
-
records.push(BitbucketCommon.vcsUser(finalUser, source));
|
|
129
|
-
}
|
|
130
|
-
return records;
|
|
131
|
-
}
|
|
132
|
-
// Replace non-null user attributes to our copy of the user
|
|
133
|
-
// e.g. accountId, displayName, emailAddress, type, links.
|
|
134
|
-
getFinalUser(users) {
|
|
135
|
-
const finalUser = {};
|
|
136
|
-
for (const user of users) {
|
|
137
|
-
for (const key in user) {
|
|
138
|
-
if (!finalUser[key] && user[key]) {
|
|
139
|
-
finalUser[key] = user[key];
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return finalUser;
|
|
144
|
-
}
|
|
145
50
|
}
|
|
146
51
|
exports.BitbucketConverter = BitbucketConverter;
|
|
147
52
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/converters/bitbucket/common.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/converters/bitbucket/common.ts"],"names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O,CACL,MAAA,MAAA,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,0CAAE,sBAAsB,mCACjD,eAAe,CAAC,sBAAsB,CACvC,CAAC;IACJ,CAAC;CACF;AA7BD,gDA6BC"}
|
package/lib/converters/bitbucket/{pull_request_activities.d.ts → pull_requests_with_activities.d.ts}
RENAMED
|
@@ -2,11 +2,18 @@ import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
|
2
2
|
import { PRActivity } from 'faros-airbyte-common/bitbucket';
|
|
3
3
|
import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
|
|
4
4
|
import { BitbucketConverter } from './common';
|
|
5
|
-
export declare class
|
|
5
|
+
export declare class PullRequestsWithActivities extends BitbucketConverter {
|
|
6
|
+
private readonly fileCollector;
|
|
6
7
|
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
7
8
|
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
9
|
+
private processPullRequest;
|
|
10
|
+
private processDiffStat;
|
|
11
|
+
onProcessingComplete(ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
12
|
+
private toPrState;
|
|
13
|
+
private processActivity;
|
|
8
14
|
reviewState(prActivity: PRActivity): {
|
|
9
15
|
category: string;
|
|
10
16
|
detail: string | null;
|
|
11
17
|
} | undefined;
|
|
18
|
+
private calculateDiffStats;
|
|
12
19
|
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PullRequestsWithActivities = void 0;
|
|
4
|
+
const faros_js_client_1 = require("faros-js-client");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const vcs_1 = require("../common/vcs");
|
|
7
|
+
const common_1 = require("./common");
|
|
8
|
+
var PullRequestStateCategory;
|
|
9
|
+
(function (PullRequestStateCategory) {
|
|
10
|
+
PullRequestStateCategory["CLOSED"] = "Closed";
|
|
11
|
+
PullRequestStateCategory["MERGED"] = "Merged";
|
|
12
|
+
PullRequestStateCategory["OPEN"] = "Open";
|
|
13
|
+
PullRequestStateCategory["CUSTOM"] = "Custom";
|
|
14
|
+
})(PullRequestStateCategory || (PullRequestStateCategory = {}));
|
|
15
|
+
var PullRequestReviewStateCategory;
|
|
16
|
+
(function (PullRequestReviewStateCategory) {
|
|
17
|
+
PullRequestReviewStateCategory["APPROVED"] = "Approved";
|
|
18
|
+
PullRequestReviewStateCategory["COMMENTED"] = "Commented";
|
|
19
|
+
PullRequestReviewStateCategory["CHANGES_REQUESTED"] = "ChangesRequested";
|
|
20
|
+
PullRequestReviewStateCategory["DISMISSED"] = "Dismissed";
|
|
21
|
+
PullRequestReviewStateCategory["CUSTOM"] = "Custom";
|
|
22
|
+
})(PullRequestReviewStateCategory || (PullRequestReviewStateCategory = {}));
|
|
23
|
+
class PullRequestsWithActivities extends common_1.BitbucketConverter {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.fileCollector = new vcs_1.FileCollector();
|
|
27
|
+
this.destinationModels = [
|
|
28
|
+
'vcs_File',
|
|
29
|
+
'vcs_PullRequest',
|
|
30
|
+
'vcs_PullRequestComment',
|
|
31
|
+
'vcs_PullRequestFile',
|
|
32
|
+
'vcs_PullRequestReview',
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
async convert(record, ctx) {
|
|
36
|
+
const { type, pullRequest, activity } = record.record
|
|
37
|
+
.data;
|
|
38
|
+
if (type === 'PullRequest') {
|
|
39
|
+
return this.processPullRequest(pullRequest, ctx);
|
|
40
|
+
}
|
|
41
|
+
else if (type === 'PullRequestActivity') {
|
|
42
|
+
return this.processActivity(activity, ctx);
|
|
43
|
+
}
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
processPullRequest(pullRequest, ctx) {
|
|
47
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
48
|
+
const source = this.streamName.source;
|
|
49
|
+
const res = [];
|
|
50
|
+
const [workspace, repo] = (((_b = (_a = pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.source) === null || _a === void 0 ? void 0 : _a.repository) === null || _b === void 0 ? void 0 : _b.fullName) ||
|
|
51
|
+
((_d = (_c = pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.destination) === null || _c === void 0 ? void 0 : _c.repository) === null || _d === void 0 ? void 0 : _d.fullName) ||
|
|
52
|
+
'').split('/');
|
|
53
|
+
if (!workspace || !repo)
|
|
54
|
+
return res;
|
|
55
|
+
const repoKey = common_1.BitbucketCommon.vcs_Repository(workspace, repo, source);
|
|
56
|
+
const commitHash = (_e = pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.mergeCommit) === null || _e === void 0 ? void 0 : _e.hash;
|
|
57
|
+
const mergeCommit = commitHash
|
|
58
|
+
? { repository: repoKey, sha: commitHash, uid: commitHash }
|
|
59
|
+
: null;
|
|
60
|
+
let author = null;
|
|
61
|
+
if ((_f = pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.author) === null || _f === void 0 ? void 0 : _f.accountId) {
|
|
62
|
+
author = { uid: pullRequest.author.accountId, source };
|
|
63
|
+
}
|
|
64
|
+
(_g = pullRequest.diffStats) === null || _g === void 0 ? void 0 : _g.forEach((diff) => {
|
|
65
|
+
res.push(...this.processDiffStat(repoKey, pullRequest, diff));
|
|
66
|
+
});
|
|
67
|
+
res.push({
|
|
68
|
+
model: 'vcs_PullRequest',
|
|
69
|
+
record: {
|
|
70
|
+
number: pullRequest.id,
|
|
71
|
+
uid: pullRequest.id.toString(),
|
|
72
|
+
title: pullRequest.title,
|
|
73
|
+
description: faros_js_client_1.Utils.cleanAndTruncate(pullRequest.description, this.maxDescriptionLength(ctx)),
|
|
74
|
+
state: this.toPrState(pullRequest.state),
|
|
75
|
+
htmlUrl: (_h = pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.links) === null || _h === void 0 ? void 0 : _h.htmlUrl,
|
|
76
|
+
createdAt: faros_js_client_1.Utils.toDate(pullRequest.createdOn),
|
|
77
|
+
updatedAt: faros_js_client_1.Utils.toDate(pullRequest.updatedOn),
|
|
78
|
+
mergedAt: faros_js_client_1.Utils.toDate((_j = pullRequest.calculatedActivity) === null || _j === void 0 ? void 0 : _j.mergedAt),
|
|
79
|
+
commentCount: pullRequest.commentCount,
|
|
80
|
+
commitCount: (_k = pullRequest.calculatedActivity) === null || _k === void 0 ? void 0 : _k.commitCount,
|
|
81
|
+
diffStats: this.calculateDiffStats(pullRequest),
|
|
82
|
+
author,
|
|
83
|
+
mergeCommit,
|
|
84
|
+
repository: repoKey,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
return res;
|
|
88
|
+
}
|
|
89
|
+
processDiffStat(repoKey, pullRequest, diff) {
|
|
90
|
+
var _a, _b, _c;
|
|
91
|
+
const res = [];
|
|
92
|
+
const processDiffPath = (path) => {
|
|
93
|
+
this.fileCollector.collectFile(path, repoKey);
|
|
94
|
+
return {
|
|
95
|
+
model: 'vcs_PullRequestFile',
|
|
96
|
+
record: {
|
|
97
|
+
pullRequest: {
|
|
98
|
+
number: pullRequest.id,
|
|
99
|
+
uid: pullRequest.id.toString(),
|
|
100
|
+
repository: repoKey,
|
|
101
|
+
},
|
|
102
|
+
file: { uid: path, repository: repoKey },
|
|
103
|
+
additions: diff.linesAdded,
|
|
104
|
+
deletions: diff.linesRemoved,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
if ((_a = diff.old) === null || _a === void 0 ? void 0 : _a.path) {
|
|
109
|
+
res.push(processDiffPath(diff.old.path));
|
|
110
|
+
}
|
|
111
|
+
if (((_b = diff.new) === null || _b === void 0 ? void 0 : _b.path) && diff.new.path !== ((_c = diff.old) === null || _c === void 0 ? void 0 : _c.path)) {
|
|
112
|
+
res.push(processDiffPath(diff.new.path));
|
|
113
|
+
}
|
|
114
|
+
return res;
|
|
115
|
+
}
|
|
116
|
+
async onProcessingComplete(ctx) {
|
|
117
|
+
return [...this.fileCollector.convertFiles()];
|
|
118
|
+
}
|
|
119
|
+
toPrState(state) {
|
|
120
|
+
const stateLower = state === null || state === void 0 ? void 0 : state.toLowerCase();
|
|
121
|
+
switch (stateLower) {
|
|
122
|
+
case 'open':
|
|
123
|
+
return { category: PullRequestStateCategory.OPEN, detail: stateLower };
|
|
124
|
+
case 'merged':
|
|
125
|
+
return { category: PullRequestStateCategory.MERGED, detail: stateLower };
|
|
126
|
+
case 'superseded':
|
|
127
|
+
case 'declined':
|
|
128
|
+
return { category: PullRequestStateCategory.CLOSED, detail: stateLower };
|
|
129
|
+
default:
|
|
130
|
+
return { category: PullRequestStateCategory.CUSTOM, detail: stateLower };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
processActivity(prActivity, ctx) {
|
|
134
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
135
|
+
const source = this.streamName.source;
|
|
136
|
+
const res = [];
|
|
137
|
+
const change = (_c = (_b = (_a = prActivity === null || prActivity === void 0 ? void 0 : prActivity.comment) !== null && _a !== void 0 ? _a : prActivity === null || prActivity === void 0 ? void 0 : prActivity.approval) !== null && _b !== void 0 ? _b : prActivity === null || prActivity === void 0 ? void 0 : prActivity.changes_requested) !== null && _c !== void 0 ? _c : prActivity === null || prActivity === void 0 ? void 0 : prActivity.update;
|
|
138
|
+
const date = faros_js_client_1.Utils.toDate((_e = (_d = change === null || change === void 0 ? void 0 : change.date) !== null && _d !== void 0 ? _d : change === null || change === void 0 ? void 0 : change.updated_on) !== null && _e !== void 0 ? _e : change === null || change === void 0 ? void 0 : change.created_on);
|
|
139
|
+
const state = this.reviewState(prActivity);
|
|
140
|
+
if (!change || !state)
|
|
141
|
+
return res;
|
|
142
|
+
const id = (_f = change === null || change === void 0 ? void 0 : change.id) !== null && _f !== void 0 ? _f : date === null || date === void 0 ? void 0 : date.getUTCMilliseconds();
|
|
143
|
+
if (!id) {
|
|
144
|
+
ctx.logger.info(`Ignored activity for pull request ${prActivity.pullRequest.id} in repo ${prActivity.pullRequest.repositorySlug}, since it has no id: ${JSON.stringify(change)}`);
|
|
145
|
+
return res;
|
|
146
|
+
}
|
|
147
|
+
const user = (_g = change === null || change === void 0 ? void 0 : change.author) !== null && _g !== void 0 ? _g : change === null || change === void 0 ? void 0 : change.user;
|
|
148
|
+
const reviewer = (user === null || user === void 0 ? void 0 : user.accountId) ? { uid: user.accountId, source } : null;
|
|
149
|
+
const { workspace, repositorySlug } = prActivity.pullRequest;
|
|
150
|
+
if (!workspace || !repositorySlug) {
|
|
151
|
+
ctx.logger.info(`Pull request activity has no repository or workspace ref: ${JSON.stringify(prActivity)}`);
|
|
152
|
+
return res;
|
|
153
|
+
}
|
|
154
|
+
const repoRef = common_1.BitbucketCommon.vcs_Repository(workspace, repositorySlug, source);
|
|
155
|
+
const pullRequest = {
|
|
156
|
+
repository: repoRef,
|
|
157
|
+
number: prActivity.pullRequest.id,
|
|
158
|
+
uid: prActivity.pullRequest.id.toString(),
|
|
159
|
+
};
|
|
160
|
+
if (prActivity === null || prActivity === void 0 ? void 0 : prActivity.comment) {
|
|
161
|
+
res.push({
|
|
162
|
+
model: 'vcs_PullRequestComment',
|
|
163
|
+
record: {
|
|
164
|
+
number: id,
|
|
165
|
+
uid: id.toString(),
|
|
166
|
+
comment: faros_js_client_1.Utils.cleanAndTruncate((_h = change === null || change === void 0 ? void 0 : change.content) === null || _h === void 0 ? void 0 : _h.raw, common_1.BitbucketCommon.MAX_DESCRIPTION_LENGTH),
|
|
167
|
+
createdAt: faros_js_client_1.Utils.toDate(change === null || change === void 0 ? void 0 : change.created_on),
|
|
168
|
+
updatedAt: faros_js_client_1.Utils.toDate(change === null || change === void 0 ? void 0 : change.updated_on),
|
|
169
|
+
author: reviewer,
|
|
170
|
+
pullRequest,
|
|
171
|
+
},
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
res.push({
|
|
175
|
+
model: 'vcs_PullRequestReview',
|
|
176
|
+
record: {
|
|
177
|
+
number: id,
|
|
178
|
+
uid: id.toString(),
|
|
179
|
+
htmlUrl: prActivity.pullRequest.links.htmlUrl,
|
|
180
|
+
pullRequest,
|
|
181
|
+
reviewer,
|
|
182
|
+
state,
|
|
183
|
+
submittedAt: date,
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
return res;
|
|
187
|
+
}
|
|
188
|
+
reviewState(prActivity) {
|
|
189
|
+
var _a;
|
|
190
|
+
// We are only considering a subset of activities on the PR and ignoring everything else
|
|
191
|
+
if (prActivity === null || prActivity === void 0 ? void 0 : prActivity.comment)
|
|
192
|
+
return { category: PullRequestReviewStateCategory.COMMENTED, detail: null };
|
|
193
|
+
if (prActivity === null || prActivity === void 0 ? void 0 : prActivity.approval)
|
|
194
|
+
return { category: PullRequestReviewStateCategory.APPROVED, detail: null };
|
|
195
|
+
if (prActivity === null || prActivity === void 0 ? void 0 : prActivity.changes_requested)
|
|
196
|
+
return {
|
|
197
|
+
category: PullRequestReviewStateCategory.CHANGES_REQUESTED,
|
|
198
|
+
detail: null,
|
|
199
|
+
};
|
|
200
|
+
if ((prActivity === null || prActivity === void 0 ? void 0 : prActivity.update) && ((_a = prActivity === null || prActivity === void 0 ? void 0 : prActivity.update) === null || _a === void 0 ? void 0 : _a.state) === 'DECLINED')
|
|
201
|
+
return { category: PullRequestReviewStateCategory.DISMISSED, detail: null };
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
calculateDiffStats(pullRequest) {
|
|
205
|
+
if (!pullRequest.diffStats) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
const filesChanged = new Set(pullRequest.diffStats
|
|
209
|
+
.flatMap((diff) => { var _a, _b; return [(_a = diff.old) === null || _a === void 0 ? void 0 : _a.path, (_b = diff.new) === null || _b === void 0 ? void 0 : _b.path]; })
|
|
210
|
+
.filter((path) => !(0, lodash_1.isNil)(path))).size;
|
|
211
|
+
const linesAdded = pullRequest.diffStats.reduce((sum, diff) => sum + diff.linesAdded, 0);
|
|
212
|
+
const linesDeleted = pullRequest.diffStats.reduce((sum, diff) => sum + diff.linesRemoved, 0);
|
|
213
|
+
return {
|
|
214
|
+
filesChanged,
|
|
215
|
+
linesAdded,
|
|
216
|
+
linesDeleted,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
exports.PullRequestsWithActivities = PullRequestsWithActivities;
|
|
221
|
+
//# sourceMappingURL=pull_requests_with_activities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pull_requests_with_activities.js","sourceRoot":"","sources":["../../../src/converters/bitbucket/pull_requests_with_activities.ts"],"names":[],"mappings":";;;AAQA,qDAAsC;AACtC,mCAA6B;AAE7B,uCAAqD;AAErD,qCAA0E;AAE1E,IAAK,wBAKJ;AALD,WAAK,wBAAwB;IAC3B,6CAAiB,CAAA;IACjB,6CAAiB,CAAA;IACjB,yCAAa,CAAA;IACb,6CAAiB,CAAA;AACnB,CAAC,EALI,wBAAwB,KAAxB,wBAAwB,QAK5B;AAED,IAAK,8BAMJ;AAND,WAAK,8BAA8B;IACjC,uDAAqB,CAAA;IACrB,yDAAuB,CAAA;IACvB,wEAAsC,CAAA;IACtC,yDAAuB,CAAA;IACvB,mDAAiB,CAAA;AACnB,CAAC,EANI,8BAA8B,KAA9B,8BAA8B,QAMlC;AAQD,MAAa,0BAA2B,SAAQ,2BAAkB;IAAlE;;QACmB,kBAAa,GAAG,IAAI,mBAAa,EAAE,CAAC;QAE5C,sBAAiB,GAAoC;YAC5D,UAAU;YACV,iBAAiB;YACjB,wBAAwB;YACxB,qBAAqB;YACrB,uBAAuB;SACxB,CAAC;IA8PJ,CAAC;IA5PC,KAAK,CAAC,OAAO,CACX,MAAqB,EACrB,GAAkB;QAElB,MAAM,EAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAC,GAAG,MAAM,CAAC,MAAM;aAChD,IAA6B,CAAC;QACjC,IAAI,IAAI,KAAK,aAAa,EAAE,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,GAAG,GAAG,IAAI,CAAC,YAAY,EACtC,CAAC,CACF,CAAC;QAEF,OAAO;YACL,YAAY;YACZ,UAAU;YACV,YAAY;SACb,CAAC;IACJ,CAAC;CACF;AAvQD,gEAuQC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
|
|
3
|
+
import { BitbucketConverter } from './common';
|
|
4
|
+
export declare class Tags extends BitbucketConverter {
|
|
5
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tags = void 0;
|
|
4
|
+
const common_1 = require("./common");
|
|
5
|
+
class Tags extends common_1.BitbucketConverter {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.destinationModels = ['vcs_Tag'];
|
|
9
|
+
}
|
|
10
|
+
async convert(record, ctx) {
|
|
11
|
+
var _a;
|
|
12
|
+
const source = this.streamName.source;
|
|
13
|
+
const tag = record.record.data;
|
|
14
|
+
const sha = (_a = tag.target) === null || _a === void 0 ? void 0 : _a.hash;
|
|
15
|
+
if (!sha) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const [workspace, repo] = tag.repository.fullName.split('/');
|
|
19
|
+
if (!workspace || !repo) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
const repository = common_1.BitbucketCommon.vcs_Repository(workspace, repo, source);
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
model: 'vcs_Tag',
|
|
26
|
+
record: {
|
|
27
|
+
name: tag.name,
|
|
28
|
+
message: tag.message,
|
|
29
|
+
commit: { sha, uid: sha, repository },
|
|
30
|
+
repository,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.Tags = Tags;
|
|
37
|
+
//# sourceMappingURL=tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../../src/converters/bitbucket/tags.ts"],"names":[],"mappings":";;;AAIA,qCAA6D;AAE7D,MAAa,IAAK,SAAQ,2BAAkB;IAA5C;;QACW,sBAAiB,GAAoC,CAAC,SAAS,CAAC,CAAC;IAiC5E,CAAC;IA/BC,KAAK,CAAC,OAAO,CACX,MAAqB,EACrB,GAAkB;;QAElB,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QACtC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,IAAW,CAAC;QAEtC,MAAM,GAAG,GAAG,MAAA,GAAG,CAAC,MAAM,0CAAE,IAAI,CAAC;QAC7B,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE7D,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,EAAE,CAAC;YACxB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,UAAU,GAAG,wBAAe,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC3E,OAAO;YACL;gBACE,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE;oBACN,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,OAAO,EAAE,GAAG,CAAC,OAAO;oBACpB,MAAM,EAAE,EAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,UAAU,EAAC;oBACnC,UAAU;iBACX;aACF;SACF,CAAC;IACJ,CAAC;CACF;AAlCD,oBAkCC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
-
import { DestinationModel, DestinationRecord
|
|
2
|
+
import { DestinationModel, DestinationRecord } from '../converter';
|
|
3
3
|
import { BitbucketConverter } from './common';
|
|
4
4
|
export declare class WorkspaceUsers extends BitbucketConverter {
|
|
5
5
|
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
6
|
convert(record: AirbyteRecord): Promise<ReadonlyArray<DestinationRecord>>;
|
|
7
|
-
onProcessingComplete(ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
8
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WorkspaceUsers = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
4
5
|
const common_1 = require("./common");
|
|
5
6
|
class WorkspaceUsers extends common_1.BitbucketConverter {
|
|
6
7
|
constructor() {
|
|
@@ -11,12 +12,37 @@ class WorkspaceUsers extends common_1.BitbucketConverter {
|
|
|
11
12
|
];
|
|
12
13
|
}
|
|
13
14
|
async convert(record) {
|
|
14
|
-
|
|
15
|
-
this.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
var _a;
|
|
16
|
+
const source = this.streamName.source;
|
|
17
|
+
const { user, workspace } = record.record.data;
|
|
18
|
+
if (!(user === null || user === void 0 ? void 0 : user.accountId))
|
|
19
|
+
return [];
|
|
20
|
+
const userType = user.type === 'user'
|
|
21
|
+
? { category: common_1.UserTypeCategory.USER, detail: 'user' }
|
|
22
|
+
: { category: common_1.UserTypeCategory.CUSTOM, detail: user.type };
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
model: 'vcs_User',
|
|
26
|
+
record: {
|
|
27
|
+
uid: user.accountId,
|
|
28
|
+
name: user.displayName,
|
|
29
|
+
email: user.emailAddress,
|
|
30
|
+
type: userType,
|
|
31
|
+
htmlUrl: (_a = user.links) === null || _a === void 0 ? void 0 : _a.htmlUrl,
|
|
32
|
+
source,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
model: 'vcs_Membership',
|
|
37
|
+
record: {
|
|
38
|
+
user: { uid: user.accountId, source },
|
|
39
|
+
organization: {
|
|
40
|
+
uid: (0, lodash_1.toLower)(workspace.slug),
|
|
41
|
+
source,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
];
|
|
20
46
|
}
|
|
21
47
|
}
|
|
22
48
|
exports.WorkspaceUsers = WorkspaceUsers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspace_users.js","sourceRoot":"","sources":["../../../src/converters/bitbucket/workspace_users.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"workspace_users.js","sourceRoot":"","sources":["../../../src/converters/bitbucket/workspace_users.ts"],"names":[],"mappings":";;;AAEA,mCAA+B;AAG/B,qCAA8D;AAE9D,MAAa,cAAe,SAAQ,2BAAkB;IAAtD;;QACW,sBAAiB,GAAoC;YAC5D,UAAU;YACV,gBAAgB;SACjB,CAAC;IAuCJ,CAAC;IArCC,KAAK,CAAC,OAAO,CACX,MAAqB;;QAErB,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;QACtC,MAAM,EAAC,IAAI,EAAE,SAAS,EAAC,GAAG,MAAM,CAAC,MAAM,CAAC,IAAqB,CAAC;QAE9D,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,CAAA;YAAE,OAAO,EAAE,CAAC;QAEhC,MAAM,QAAQ,GACZ,IAAI,CAAC,IAAI,KAAK,MAAM;YAClB,CAAC,CAAC,EAAC,QAAQ,EAAE,yBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM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