airbyte-faros-destination 0.1.53
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/README.md +161 -0
- package/lib/common/write-stats.d.ts +16 -0
- package/lib/common/write-stats.js +48 -0
- package/lib/community/hasura-client.d.ts +27 -0
- package/lib/community/hasura-client.js +278 -0
- package/lib/community/hasura-writer.d.ts +12 -0
- package/lib/community/hasura-writer.js +44 -0
- package/lib/community/types.d.ts +26 -0
- package/lib/community/types.js +9 -0
- package/lib/converters/agileaccelerator/agileaccelerator_types.d.ts +315 -0
- package/lib/converters/agileaccelerator/agileaccelerator_types.js +81 -0
- package/lib/converters/agileaccelerator/common.d.ts +64 -0
- package/lib/converters/agileaccelerator/common.js +167 -0
- package/lib/converters/agileaccelerator/works.d.ts +7 -0
- package/lib/converters/agileaccelerator/works.js +105 -0
- package/lib/converters/asana/common.d.ts +39 -0
- package/lib/converters/asana/common.js +64 -0
- package/lib/converters/asana/projects.d.ts +7 -0
- package/lib/converters/asana/projects.js +29 -0
- package/lib/converters/asana/sections.d.ts +7 -0
- package/lib/converters/asana/sections.js +28 -0
- package/lib/converters/asana/stories.d.ts +7 -0
- package/lib/converters/asana/stories.js +32 -0
- package/lib/converters/asana/tags.d.ts +7 -0
- package/lib/converters/asana/tags.js +22 -0
- package/lib/converters/asana/tasks.d.ts +11 -0
- package/lib/converters/asana/tasks.js +160 -0
- package/lib/converters/asana/users.d.ts +7 -0
- package/lib/converters/asana/users.js +16 -0
- package/lib/converters/backlog/common.d.ts +20 -0
- package/lib/converters/backlog/common.js +59 -0
- package/lib/converters/backlog/issues.d.ts +7 -0
- package/lib/converters/backlog/issues.js +119 -0
- package/lib/converters/backlog/models.d.ts +156 -0
- package/lib/converters/backlog/models.js +23 -0
- package/lib/converters/backlog/projects.d.ts +7 -0
- package/lib/converters/backlog/projects.js +78 -0
- package/lib/converters/backlog/users.d.ts +7 -0
- package/lib/converters/backlog/users.js +26 -0
- package/lib/converters/bitbucket/branches.d.ts +7 -0
- package/lib/converters/bitbucket/branches.js +31 -0
- package/lib/converters/bitbucket/commits.d.ts +7 -0
- package/lib/converters/bitbucket/commits.js +50 -0
- package/lib/converters/bitbucket/common.d.ts +28 -0
- package/lib/converters/bitbucket/common.js +56 -0
- package/lib/converters/bitbucket/deployments.d.ts +11 -0
- package/lib/converters/bitbucket/deployments.js +100 -0
- package/lib/converters/bitbucket/issues.d.ts +12 -0
- package/lib/converters/bitbucket/issues.js +111 -0
- package/lib/converters/bitbucket/pipeline_steps.d.ts +10 -0
- package/lib/converters/bitbucket/pipeline_steps.js +83 -0
- package/lib/converters/bitbucket/pipelines.d.ts +8 -0
- package/lib/converters/bitbucket/pipelines.js +90 -0
- package/lib/converters/bitbucket/pull_request_activities.d.ts +13 -0
- package/lib/converters/bitbucket/pull_request_activities.js +112 -0
- package/lib/converters/bitbucket/pull_requests.d.ts +10 -0
- package/lib/converters/bitbucket/pull_requests.js +95 -0
- package/lib/converters/bitbucket/repositories.d.ts +9 -0
- package/lib/converters/bitbucket/repositories.js +41 -0
- package/lib/converters/bitbucket/types.d.ts +667 -0
- package/lib/converters/bitbucket/types.js +2 -0
- package/lib/converters/bitbucket/workspace_users.d.ts +7 -0
- package/lib/converters/bitbucket/workspace_users.js +31 -0
- package/lib/converters/bitbucket/workspaces.d.ts +8 -0
- package/lib/converters/bitbucket/workspaces.js +61 -0
- package/lib/converters/converter-registry.d.ts +25 -0
- package/lib/converters/converter-registry.js +64 -0
- package/lib/converters/converter.d.ts +63 -0
- package/lib/converters/converter.js +122 -0
- package/lib/converters/datadog/common.d.ts +27 -0
- package/lib/converters/datadog/common.js +34 -0
- package/lib/converters/datadog/incidents.d.ts +9 -0
- package/lib/converters/datadog/incidents.js +128 -0
- package/lib/converters/datadog/users.d.ts +7 -0
- package/lib/converters/datadog/users.js +27 -0
- package/lib/converters/docker/common.d.ts +87 -0
- package/lib/converters/docker/common.js +76 -0
- package/lib/converters/docker/tags.d.ts +8 -0
- package/lib/converters/docker/tags.js +98 -0
- package/lib/converters/github/assignees.d.ts +7 -0
- package/lib/converters/github/assignees.js +16 -0
- package/lib/converters/github/branches.d.ts +7 -0
- package/lib/converters/github/branches.js +28 -0
- package/lib/converters/github/collaborators.d.ts +7 -0
- package/lib/converters/github/collaborators.js +19 -0
- package/lib/converters/github/commits.d.ts +7 -0
- package/lib/converters/github/commits.js +48 -0
- package/lib/converters/github/common.d.ts +37 -0
- package/lib/converters/github/common.js +130 -0
- package/lib/converters/github/issue_labels.d.ts +7 -0
- package/lib/converters/github/issue_labels.js +20 -0
- package/lib/converters/github/issue_milestones.d.ts +8 -0
- package/lib/converters/github/issue_milestones.js +42 -0
- package/lib/converters/github/issues.d.ts +9 -0
- package/lib/converters/github/issues.js +90 -0
- package/lib/converters/github/organizations.d.ts +7 -0
- package/lib/converters/github/organizations.js +37 -0
- package/lib/converters/github/projects.d.ts +7 -0
- package/lib/converters/github/projects.js +21 -0
- package/lib/converters/github/pull_request_stats.d.ts +7 -0
- package/lib/converters/github/pull_request_stats.js +43 -0
- package/lib/converters/github/pull_requests.d.ts +7 -0
- package/lib/converters/github/pull_requests.js +63 -0
- package/lib/converters/github/releases.d.ts +7 -0
- package/lib/converters/github/releases.js +51 -0
- package/lib/converters/github/repositories.d.ts +7 -0
- package/lib/converters/github/repositories.js +44 -0
- package/lib/converters/github/review_comments.d.ts +7 -0
- package/lib/converters/github/review_comments.js +39 -0
- package/lib/converters/github/reviews.d.ts +7 -0
- package/lib/converters/github/reviews.js +58 -0
- package/lib/converters/github/tags.d.ts +7 -0
- package/lib/converters/github/tags.js +31 -0
- package/lib/converters/github/users.d.ts +7 -0
- package/lib/converters/github/users.js +19 -0
- package/lib/converters/gitlab/branches.d.ts +8 -0
- package/lib/converters/gitlab/branches.js +44 -0
- package/lib/converters/gitlab/commits.d.ts +7 -0
- package/lib/converters/gitlab/commits.js +33 -0
- package/lib/converters/gitlab/common.d.ts +30 -0
- package/lib/converters/gitlab/common.js +70 -0
- package/lib/converters/gitlab/group_labels.d.ts +7 -0
- package/lib/converters/gitlab/group_labels.js +15 -0
- package/lib/converters/gitlab/group_milestones.d.ts +8 -0
- package/lib/converters/gitlab/group_milestones.js +41 -0
- package/lib/converters/gitlab/groups.d.ts +7 -0
- package/lib/converters/gitlab/groups.js +43 -0
- package/lib/converters/gitlab/issues.d.ts +10 -0
- package/lib/converters/gitlab/issues.js +79 -0
- package/lib/converters/gitlab/jobs.d.ts +11 -0
- package/lib/converters/gitlab/jobs.js +75 -0
- package/lib/converters/gitlab/merge_request_commits.d.ts +7 -0
- package/lib/converters/gitlab/merge_request_commits.js +34 -0
- package/lib/converters/gitlab/merge_requests.d.ts +10 -0
- package/lib/converters/gitlab/merge_requests.js +65 -0
- package/lib/converters/gitlab/pipelines.d.ts +7 -0
- package/lib/converters/gitlab/pipelines.js +41 -0
- package/lib/converters/gitlab/project_labels.d.ts +7 -0
- package/lib/converters/gitlab/project_labels.js +15 -0
- package/lib/converters/gitlab/project_milestones.d.ts +8 -0
- package/lib/converters/gitlab/project_milestones.js +41 -0
- package/lib/converters/gitlab/projects.d.ts +7 -0
- package/lib/converters/gitlab/projects.js +51 -0
- package/lib/converters/gitlab/releases.d.ts +10 -0
- package/lib/converters/gitlab/releases.js +68 -0
- package/lib/converters/gitlab/tags.d.ts +10 -0
- package/lib/converters/gitlab/tags.js +41 -0
- package/lib/converters/gitlab/users.d.ts +7 -0
- package/lib/converters/gitlab/users.js +33 -0
- package/lib/converters/googlecalendar/calendar_models.d.ts +618 -0
- package/lib/converters/googlecalendar/calendar_models.js +2 -0
- package/lib/converters/googlecalendar/calendars.d.ts +7 -0
- package/lib/converters/googlecalendar/calendars.js +29 -0
- package/lib/converters/googlecalendar/common.d.ts +52 -0
- package/lib/converters/googlecalendar/common.js +130 -0
- package/lib/converters/googlecalendar/events.d.ts +8 -0
- package/lib/converters/googlecalendar/events.js +117 -0
- package/lib/converters/harness/common.d.ts +105 -0
- package/lib/converters/harness/common.js +16 -0
- package/lib/converters/harness/executions.d.ts +15 -0
- package/lib/converters/harness/executions.js +245 -0
- package/lib/converters/jenkins/builds.d.ts +9 -0
- package/lib/converters/jenkins/builds.js +74 -0
- package/lib/converters/jenkins/common.d.ts +25 -0
- package/lib/converters/jenkins/common.js +54 -0
- package/lib/converters/jenkins/jobs.d.ts +8 -0
- package/lib/converters/jenkins/jobs.js +29 -0
- package/lib/converters/jira/board_issues.d.ts +7 -0
- package/lib/converters/jira/board_issues.js +28 -0
- package/lib/converters/jira/boards.d.ts +7 -0
- package/lib/converters/jira/boards.js +34 -0
- package/lib/converters/jira/common.d.ts +61 -0
- package/lib/converters/jira/common.js +64 -0
- package/lib/converters/jira/epics.d.ts +8 -0
- package/lib/converters/jira/epics.js +45 -0
- package/lib/converters/jira/issue_fields.d.ts +7 -0
- package/lib/converters/jira/issue_fields.js +15 -0
- package/lib/converters/jira/issues.d.ts +52 -0
- package/lib/converters/jira/issues.js +545 -0
- package/lib/converters/jira/project_versions.d.ts +9 -0
- package/lib/converters/jira/project_versions.js +48 -0
- package/lib/converters/jira/projects.d.ts +7 -0
- package/lib/converters/jira/projects.js +40 -0
- package/lib/converters/jira/pull_requests.d.ts +7 -0
- package/lib/converters/jira/pull_requests.js +15 -0
- package/lib/converters/jira/sprint_issues.d.ts +7 -0
- package/lib/converters/jira/sprint_issues.js +15 -0
- package/lib/converters/jira/sprints.d.ts +16 -0
- package/lib/converters/jira/sprints.js +80 -0
- package/lib/converters/jira/users.d.ts +8 -0
- package/lib/converters/jira/users.js +33 -0
- package/lib/converters/jira/workflow_statuses.d.ts +7 -0
- package/lib/converters/jira/workflow_statuses.js +15 -0
- package/lib/converters/jsonata.d.ts +17 -0
- package/lib/converters/jsonata.js +47 -0
- package/lib/converters/okta/common.d.ts +8 -0
- package/lib/converters/okta/common.js +17 -0
- package/lib/converters/okta/groups.d.ts +7 -0
- package/lib/converters/okta/groups.js +47 -0
- package/lib/converters/okta/models.d.ts +102 -0
- package/lib/converters/okta/models.js +2 -0
- package/lib/converters/okta/users.d.ts +8 -0
- package/lib/converters/okta/users.js +73 -0
- package/lib/converters/okta_faros/common.d.ts +4 -0
- package/lib/converters/okta_faros/common.js +11 -0
- package/lib/converters/okta_faros/groups.d.ts +13 -0
- package/lib/converters/okta_faros/groups.js +23 -0
- package/lib/converters/okta_faros/users.d.ts +13 -0
- package/lib/converters/okta_faros/users.js +23 -0
- package/lib/converters/pagerduty/common.d.ts +37 -0
- package/lib/converters/pagerduty/common.js +40 -0
- package/lib/converters/pagerduty/incident_log_entries.d.ts +8 -0
- package/lib/converters/pagerduty/incident_log_entries.js +56 -0
- package/lib/converters/pagerduty/incidents.d.ts +10 -0
- package/lib/converters/pagerduty/incidents.js +127 -0
- package/lib/converters/pagerduty/priorities_resource.d.ts +11 -0
- package/lib/converters/pagerduty/priorities_resource.js +64 -0
- package/lib/converters/pagerduty/users.d.ts +7 -0
- package/lib/converters/pagerduty/users.js +26 -0
- package/lib/converters/phabricator/commits.d.ts +8 -0
- package/lib/converters/phabricator/commits.js +75 -0
- package/lib/converters/phabricator/common.d.ts +40 -0
- package/lib/converters/phabricator/common.js +107 -0
- package/lib/converters/phabricator/repositories.d.ts +7 -0
- package/lib/converters/phabricator/repositories.js +56 -0
- package/lib/converters/phabricator/revisions.d.ts +7 -0
- package/lib/converters/phabricator/revisions.js +83 -0
- package/lib/converters/phabricator/users.d.ts +7 -0
- package/lib/converters/phabricator/users.js +39 -0
- package/lib/converters/shortcut/common.d.ts +16 -0
- package/lib/converters/shortcut/common.js +68 -0
- package/lib/converters/shortcut/epics.d.ts +7 -0
- package/lib/converters/shortcut/epics.js +29 -0
- package/lib/converters/shortcut/iterations.d.ts +7 -0
- package/lib/converters/shortcut/iterations.js +29 -0
- package/lib/converters/shortcut/members.d.ts +7 -0
- package/lib/converters/shortcut/members.js +26 -0
- package/lib/converters/shortcut/models.d.ts +392 -0
- package/lib/converters/shortcut/models.js +30 -0
- package/lib/converters/shortcut/projects.d.ts +7 -0
- package/lib/converters/shortcut/projects.js +46 -0
- package/lib/converters/shortcut/stories.d.ts +7 -0
- package/lib/converters/shortcut/stories.js +127 -0
- package/lib/converters/squadcast/common.d.ts +169 -0
- package/lib/converters/squadcast/common.js +62 -0
- package/lib/converters/squadcast/events.d.ts +9 -0
- package/lib/converters/squadcast/events.js +53 -0
- package/lib/converters/squadcast/incidents.d.ts +10 -0
- package/lib/converters/squadcast/incidents.js +141 -0
- package/lib/converters/squadcast/services.d.ts +7 -0
- package/lib/converters/squadcast/services.js +28 -0
- package/lib/converters/squadcast/users.d.ts +7 -0
- package/lib/converters/squadcast/users.js +27 -0
- package/lib/converters/statuspage/common.d.ts +93 -0
- package/lib/converters/statuspage/common.js +80 -0
- package/lib/converters/statuspage/incident_updates.d.ts +8 -0
- package/lib/converters/statuspage/incident_updates.js +45 -0
- package/lib/converters/statuspage/incidents.d.ts +10 -0
- package/lib/converters/statuspage/incidents.js +128 -0
- package/lib/converters/statuspage/users.d.ts +7 -0
- package/lib/converters/statuspage/users.js +26 -0
- package/lib/converters/victorops/common.d.ts +16 -0
- package/lib/converters/victorops/common.js +24 -0
- package/lib/converters/victorops/incidents.d.ts +12 -0
- package/lib/converters/victorops/incidents.js +209 -0
- package/lib/converters/victorops/teams.d.ts +8 -0
- package/lib/converters/victorops/teams.js +30 -0
- package/lib/converters/victorops/users.d.ts +8 -0
- package/lib/converters/victorops/users.js +33 -0
- package/lib/destination-runner.d.ts +12 -0
- package/lib/destination-runner.js +22 -0
- package/lib/destination.d.ts +42 -0
- package/lib/destination.js +508 -0
- package/lib/index.d.ts +16 -0
- package/lib/index.js +39 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +71 -0
- package/resources/fetch-primary-keys.sql +16 -0
- package/resources/introspection-query.gql +61 -0
- package/resources/spec.json +468 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Deployments = void 0;
|
|
4
|
+
const faros_feeds_sdk_1 = require("faros-feeds-sdk");
|
|
5
|
+
const converter_1 = require("../converter");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
var EnvironmentCategory;
|
|
8
|
+
(function (EnvironmentCategory) {
|
|
9
|
+
EnvironmentCategory["PROD"] = "Prod";
|
|
10
|
+
EnvironmentCategory["STAGING"] = "Staging";
|
|
11
|
+
EnvironmentCategory["QA"] = "QA";
|
|
12
|
+
EnvironmentCategory["DEV"] = "Dev";
|
|
13
|
+
EnvironmentCategory["SANDBOX"] = "Sandbox";
|
|
14
|
+
EnvironmentCategory["CUSTOM"] = "Custom";
|
|
15
|
+
})(EnvironmentCategory || (EnvironmentCategory = {}));
|
|
16
|
+
var DeploymentStatusCategory;
|
|
17
|
+
(function (DeploymentStatusCategory) {
|
|
18
|
+
DeploymentStatusCategory["CANCELED"] = "Canceled";
|
|
19
|
+
DeploymentStatusCategory["CUSTOM"] = "Custom";
|
|
20
|
+
DeploymentStatusCategory["FAILED"] = "Failed";
|
|
21
|
+
DeploymentStatusCategory["QUEUED"] = "Queued";
|
|
22
|
+
DeploymentStatusCategory["RUNNING"] = "Running";
|
|
23
|
+
DeploymentStatusCategory["ROLLED_BACK"] = "RolledBack";
|
|
24
|
+
DeploymentStatusCategory["SUCCESS"] = "Success";
|
|
25
|
+
})(DeploymentStatusCategory || (DeploymentStatusCategory = {}));
|
|
26
|
+
class Deployments extends common_1.BitbucketConverter {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.destinationModels = [
|
|
30
|
+
'cicd_Deployment',
|
|
31
|
+
];
|
|
32
|
+
this.pipelinesStream = new converter_1.StreamName('bitbucket', 'pipelines');
|
|
33
|
+
}
|
|
34
|
+
get dependencies() {
|
|
35
|
+
return [this.pipelinesStream];
|
|
36
|
+
}
|
|
37
|
+
async convert(record, ctx) {
|
|
38
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
39
|
+
const source = this.streamName.source;
|
|
40
|
+
const deployment = record.record.data;
|
|
41
|
+
const applicationMapping = this.applicationMapping(ctx);
|
|
42
|
+
const application = (_b = (applicationMapping && applicationMapping[(_a = deployment.deployable) === null || _a === void 0 ? void 0 : _a.name])) !== null && _b !== void 0 ? _b : null;
|
|
43
|
+
const pipelinesStream = this.pipelinesStream.asString;
|
|
44
|
+
const pipelineRecord = ctx.get(pipelinesStream, ((_c = deployment.commit) === null || _c === void 0 ? void 0 : _c.hash) ||
|
|
45
|
+
((_e = (_d = deployment.deployable) === null || _d === void 0 ? void 0 : _d.commit) === null || _e === void 0 ? void 0 : _e.hash) ||
|
|
46
|
+
((_g = (_f = deployment.release) === null || _f === void 0 ? void 0 : _f.commit) === null || _g === void 0 ? void 0 : _g.hash));
|
|
47
|
+
const pipeline = (_h = pipelineRecord === null || pipelineRecord === void 0 ? void 0 : pipelineRecord.record) === null || _h === void 0 ? void 0 : _h.data;
|
|
48
|
+
const [workspace, repo] = (((_j = pipeline === null || pipeline === void 0 ? void 0 : pipeline.repository) === null || _j === void 0 ? void 0 : _j.fullName) || '').split('/');
|
|
49
|
+
let build = null;
|
|
50
|
+
if (workspace && repo) {
|
|
51
|
+
const orgKey = { uid: workspace.toLowerCase(), source };
|
|
52
|
+
const pipelineKey = { organization: orgKey, uid: repo.toLowerCase() };
|
|
53
|
+
build = {
|
|
54
|
+
pipeline: pipelineKey,
|
|
55
|
+
uid: (_l = (_k = deployment.deployable) === null || _k === void 0 ? void 0 : _k.pipeline) === null || _l === void 0 ? void 0 : _l.uuid,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
model: 'cicd_Deployment',
|
|
61
|
+
record: {
|
|
62
|
+
application,
|
|
63
|
+
build,
|
|
64
|
+
uid: deployment.uuid,
|
|
65
|
+
env: this.convertEnvironment((_m = deployment.environment) === null || _m === void 0 ? void 0 : _m.slug),
|
|
66
|
+
status: this.convertDeploymentStatus(deployment.state),
|
|
67
|
+
startedAt: faros_feeds_sdk_1.Utils.toDate(deployment.deployable.createdOn),
|
|
68
|
+
source,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
convertEnvironment(env) {
|
|
74
|
+
const detail = env === null || env === void 0 ? void 0 : env.toLowerCase();
|
|
75
|
+
switch (detail) {
|
|
76
|
+
case 'test':
|
|
77
|
+
return { category: EnvironmentCategory.QA, detail };
|
|
78
|
+
case 'staging':
|
|
79
|
+
return { category: EnvironmentCategory.STAGING, detail };
|
|
80
|
+
case 'production':
|
|
81
|
+
return { category: EnvironmentCategory.PROD, detail };
|
|
82
|
+
default:
|
|
83
|
+
return { category: EnvironmentCategory.CUSTOM, detail };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
convertDeploymentStatus(state) {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
const detail = (_b = (((_a = state.status) === null || _a === void 0 ? void 0 : _a.name) || state.name)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
89
|
+
switch (detail) {
|
|
90
|
+
case 'failed':
|
|
91
|
+
return { category: DeploymentStatusCategory.FAILED, detail };
|
|
92
|
+
case 'completed':
|
|
93
|
+
case 'successful':
|
|
94
|
+
return { category: DeploymentStatusCategory.SUCCESS, detail };
|
|
95
|
+
default:
|
|
96
|
+
return { category: DeploymentStatusCategory.CUSTOM, detail };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.Deployments = Deployments;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext, StreamName } from '../converter';
|
|
3
|
+
import { BitbucketConverter } from './common';
|
|
4
|
+
export declare class Issues extends BitbucketConverter {
|
|
5
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
+
private readonly workspacesStream;
|
|
7
|
+
get dependencies(): ReadonlyArray<StreamName>;
|
|
8
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
9
|
+
private tmsUser;
|
|
10
|
+
private toTaskType;
|
|
11
|
+
private toTaskStatus;
|
|
12
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Issues = void 0;
|
|
4
|
+
const faros_feeds_sdk_1 = require("faros-feeds-sdk");
|
|
5
|
+
const converter_1 = require("../converter");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
var TaskCategory;
|
|
8
|
+
(function (TaskCategory) {
|
|
9
|
+
TaskCategory["BUG"] = "Bug";
|
|
10
|
+
TaskCategory["CUSTOM"] = "Custom";
|
|
11
|
+
TaskCategory["STORY"] = "Story";
|
|
12
|
+
TaskCategory["TASK"] = "Task";
|
|
13
|
+
})(TaskCategory || (TaskCategory = {}));
|
|
14
|
+
var TaskStatusCategory;
|
|
15
|
+
(function (TaskStatusCategory) {
|
|
16
|
+
TaskStatusCategory["CUSTOM"] = "Custom";
|
|
17
|
+
TaskStatusCategory["DONE"] = "Done";
|
|
18
|
+
TaskStatusCategory["IN_PROGRESS"] = "InProgress";
|
|
19
|
+
TaskStatusCategory["TODO"] = "Todo";
|
|
20
|
+
})(TaskStatusCategory || (TaskStatusCategory = {}));
|
|
21
|
+
class Issues extends common_1.BitbucketConverter {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.destinationModels = [
|
|
25
|
+
'tms_Task',
|
|
26
|
+
'tms_TaskAssignment',
|
|
27
|
+
'tms_User',
|
|
28
|
+
];
|
|
29
|
+
this.workspacesStream = new converter_1.StreamName('bitbucket', 'workspace');
|
|
30
|
+
}
|
|
31
|
+
get dependencies() {
|
|
32
|
+
return [this.workspacesStream];
|
|
33
|
+
}
|
|
34
|
+
async convert(record, ctx) {
|
|
35
|
+
var _a, _b, _c, _d;
|
|
36
|
+
const source = this.streamName.source;
|
|
37
|
+
const issue = record.record.data;
|
|
38
|
+
const res = [];
|
|
39
|
+
const taskRef = { uid: String(issue.id), source };
|
|
40
|
+
let creator = null;
|
|
41
|
+
if ((_a = issue === null || issue === void 0 ? void 0 : issue.reporter) === null || _a === void 0 ? void 0 : _a.accountId) {
|
|
42
|
+
creator = { uid: issue.reporter.accountId, source };
|
|
43
|
+
res.push(this.tmsUser(issue.reporter, source));
|
|
44
|
+
}
|
|
45
|
+
if ((_b = issue === null || issue === void 0 ? void 0 : issue.assignee) === null || _b === void 0 ? void 0 : _b.accountId) {
|
|
46
|
+
res.push(this.tmsUser(issue.assignee, source));
|
|
47
|
+
res.push({
|
|
48
|
+
model: 'tms_TaskAssignment',
|
|
49
|
+
record: {
|
|
50
|
+
task: taskRef,
|
|
51
|
+
assignee: { uid: issue.assignee.accountId, source },
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
res.push({
|
|
56
|
+
model: 'tms_Task',
|
|
57
|
+
record: {
|
|
58
|
+
...taskRef,
|
|
59
|
+
name: issue.title,
|
|
60
|
+
description: (_d = (_c = issue.content) === null || _c === void 0 ? void 0 : _c.raw) === null || _d === void 0 ? void 0 : _d.substring(0, common_1.BitbucketCommon.MAX_DESCRIPTION_LENGTH),
|
|
61
|
+
type: this.toTaskType(issue.kind),
|
|
62
|
+
status: this.toTaskStatus(issue.state),
|
|
63
|
+
priority: issue.priority,
|
|
64
|
+
createdAt: faros_feeds_sdk_1.Utils.toDate(issue.createdOn),
|
|
65
|
+
updatedAt: faros_feeds_sdk_1.Utils.toDate(issue.updatedOn),
|
|
66
|
+
creator,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
return res;
|
|
70
|
+
}
|
|
71
|
+
tmsUser(user, source) {
|
|
72
|
+
var _a;
|
|
73
|
+
return {
|
|
74
|
+
model: 'tms_User',
|
|
75
|
+
record: {
|
|
76
|
+
uid: (_a = user.accountId) === null || _a === void 0 ? void 0 : _a.toLowerCase(),
|
|
77
|
+
name: user.nickname,
|
|
78
|
+
source,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
toTaskType(type) {
|
|
83
|
+
const typeLower = type === null || type === void 0 ? void 0 : type.toLowerCase();
|
|
84
|
+
switch (typeLower) {
|
|
85
|
+
case 'bug':
|
|
86
|
+
return { category: TaskCategory.BUG, detail: typeLower };
|
|
87
|
+
case 'task':
|
|
88
|
+
return { category: TaskCategory.TASK, detail: typeLower };
|
|
89
|
+
default:
|
|
90
|
+
return { category: TaskCategory.CUSTOM, detail: typeLower };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
toTaskStatus(status) {
|
|
94
|
+
const statusLower = status === null || status === void 0 ? void 0 : status.toLowerCase();
|
|
95
|
+
switch (statusLower) {
|
|
96
|
+
case 'new':
|
|
97
|
+
case 'open':
|
|
98
|
+
case 'on hold':
|
|
99
|
+
case 'wontfix':
|
|
100
|
+
return { category: TaskStatusCategory.TODO, detail: statusLower };
|
|
101
|
+
case 'resolved':
|
|
102
|
+
case 'closed':
|
|
103
|
+
return { category: TaskStatusCategory.DONE, detail: statusLower };
|
|
104
|
+
case 'duplicate':
|
|
105
|
+
case 'invalid':
|
|
106
|
+
default:
|
|
107
|
+
return { category: TaskStatusCategory.CUSTOM, detail: statusLower };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.Issues = Issues;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext, StreamName } from '../converter';
|
|
3
|
+
import { BitbucketConverter } from './common';
|
|
4
|
+
export declare class PipelineSteps extends BitbucketConverter {
|
|
5
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
+
private readonly pipelinesStream;
|
|
7
|
+
get dependencies(): ReadonlyArray<StreamName>;
|
|
8
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
9
|
+
private convertBuildStatus;
|
|
10
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PipelineSteps = void 0;
|
|
4
|
+
const faros_feeds_sdk_1 = require("faros-feeds-sdk");
|
|
5
|
+
const converter_1 = require("../converter");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
var BuildStatusCategory;
|
|
8
|
+
(function (BuildStatusCategory) {
|
|
9
|
+
BuildStatusCategory["CANCELED"] = "Canceled";
|
|
10
|
+
BuildStatusCategory["FAILED"] = "Failed";
|
|
11
|
+
BuildStatusCategory["QUEUED"] = "Queued";
|
|
12
|
+
BuildStatusCategory["RUNNING"] = "Running";
|
|
13
|
+
BuildStatusCategory["SUCCESS"] = "Success";
|
|
14
|
+
BuildStatusCategory["UNKNOWN"] = "Unknown";
|
|
15
|
+
BuildStatusCategory["CUSTOM"] = "Custom";
|
|
16
|
+
})(BuildStatusCategory || (BuildStatusCategory = {}));
|
|
17
|
+
class PipelineSteps extends common_1.BitbucketConverter {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.destinationModels = [
|
|
21
|
+
'cicd_BuildStep',
|
|
22
|
+
];
|
|
23
|
+
this.pipelinesStream = new converter_1.StreamName('bitbucket', 'pipelines');
|
|
24
|
+
}
|
|
25
|
+
get dependencies() {
|
|
26
|
+
return [this.pipelinesStream];
|
|
27
|
+
}
|
|
28
|
+
async convert(record, ctx) {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
const source = this.streamName.source;
|
|
31
|
+
const step = record.record.data;
|
|
32
|
+
const pipelinesStream = this.pipelinesStream.asString;
|
|
33
|
+
const pipelinesRecord = ctx.get(pipelinesStream, step.pipeline.uuid);
|
|
34
|
+
const pipeline = (_a = pipelinesRecord === null || pipelinesRecord === void 0 ? void 0 : pipelinesRecord.record) === null || _a === void 0 ? void 0 : _a.data;
|
|
35
|
+
const [workspace, repo] = (((_b = pipeline === null || pipeline === void 0 ? void 0 : pipeline.repository) === null || _b === void 0 ? void 0 : _b.fullName) || '').split('/');
|
|
36
|
+
if (!workspace || !repo)
|
|
37
|
+
return [];
|
|
38
|
+
const orgKey = { uid: workspace.toLowerCase(), source };
|
|
39
|
+
const pipelineKey = { organization: orgKey, uid: repo.toLowerCase() };
|
|
40
|
+
const build = { pipeline: pipelineKey, uid: pipeline.uuid };
|
|
41
|
+
return [
|
|
42
|
+
{
|
|
43
|
+
model: 'cicd_BuildStep',
|
|
44
|
+
record: {
|
|
45
|
+
uid: step.uuid,
|
|
46
|
+
name: step.name,
|
|
47
|
+
startedAt: faros_feeds_sdk_1.Utils.toDate(step.startedOn),
|
|
48
|
+
endedAt: faros_feeds_sdk_1.Utils.toDate(step.completedOn),
|
|
49
|
+
status: this.convertBuildStatus(step.state),
|
|
50
|
+
build,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
convertBuildStatus(state) {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
if (!state) {
|
|
58
|
+
return { category: 'Unknown', detail: 'undefined' };
|
|
59
|
+
}
|
|
60
|
+
// We're more interest in the "result" than the "state" as this tells the true
|
|
61
|
+
// state of a pipeline build. The switch statement however takes care of all
|
|
62
|
+
// possible entries from both the "result" and "state".
|
|
63
|
+
const detail = (_b = (((_a = state.result) === null || _a === void 0 ? void 0 : _a.name) || state.name)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
64
|
+
switch (detail) {
|
|
65
|
+
case 'error':
|
|
66
|
+
case 'failed':
|
|
67
|
+
return { category: BuildStatusCategory.FAILED, detail };
|
|
68
|
+
case 'in_progress':
|
|
69
|
+
case 'running':
|
|
70
|
+
return { category: BuildStatusCategory.RUNNING, detail };
|
|
71
|
+
case 'pending':
|
|
72
|
+
return { category: BuildStatusCategory.QUEUED, detail };
|
|
73
|
+
case 'stopped':
|
|
74
|
+
return { category: BuildStatusCategory.CANCELED, detail };
|
|
75
|
+
case 'completed':
|
|
76
|
+
case 'successful':
|
|
77
|
+
return { category: BuildStatusCategory.SUCCESS, detail };
|
|
78
|
+
default:
|
|
79
|
+
return { category: BuildStatusCategory.CUSTOM, detail };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.PipelineSteps = PipelineSteps;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
|
|
3
|
+
import { BitbucketConverter } from './common';
|
|
4
|
+
export declare class Pipelines extends BitbucketConverter {
|
|
5
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
7
|
+
private convertBuildStatus;
|
|
8
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pipelines = void 0;
|
|
4
|
+
const faros_feeds_sdk_1 = require("faros-feeds-sdk");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
var BuildStatusCategory;
|
|
7
|
+
(function (BuildStatusCategory) {
|
|
8
|
+
BuildStatusCategory["CANCELED"] = "Canceled";
|
|
9
|
+
BuildStatusCategory["FAILED"] = "Failed";
|
|
10
|
+
BuildStatusCategory["QUEUED"] = "Queued";
|
|
11
|
+
BuildStatusCategory["RUNNING"] = "Running";
|
|
12
|
+
BuildStatusCategory["SUCCESS"] = "Success";
|
|
13
|
+
BuildStatusCategory["UNKNOWN"] = "Unknown";
|
|
14
|
+
BuildStatusCategory["CUSTOM"] = "Custom";
|
|
15
|
+
})(BuildStatusCategory || (BuildStatusCategory = {}));
|
|
16
|
+
class Pipelines extends common_1.BitbucketConverter {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.destinationModels = [
|
|
20
|
+
'cicd_Build',
|
|
21
|
+
'cicd_BuildCommitAssociation',
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
async convert(record, ctx) {
|
|
25
|
+
var _a, _b, _c, _d;
|
|
26
|
+
const source = this.streamName.source;
|
|
27
|
+
const pipeline = record.record.data;
|
|
28
|
+
const res = [];
|
|
29
|
+
const [workspace, repo] = (((_a = pipeline === null || pipeline === void 0 ? void 0 : pipeline.repository) === null || _a === void 0 ? void 0 : _a.fullName) || '').split('/');
|
|
30
|
+
if (!workspace || !repo)
|
|
31
|
+
return res;
|
|
32
|
+
const status = this.convertBuildStatus(pipeline.state);
|
|
33
|
+
const orgKey = { uid: workspace === null || workspace === void 0 ? void 0 : workspace.toLowerCase(), source };
|
|
34
|
+
const pipelineKey = { organization: orgKey, uid: repo === null || repo === void 0 ? void 0 : repo.toLowerCase() };
|
|
35
|
+
res.push({
|
|
36
|
+
model: 'cicd_Build',
|
|
37
|
+
record: {
|
|
38
|
+
uid: pipeline.uuid,
|
|
39
|
+
number: pipeline.buildNumber,
|
|
40
|
+
pipeline: pipelineKey,
|
|
41
|
+
status,
|
|
42
|
+
url: (_b = pipeline.links) === null || _b === void 0 ? void 0 : _b.htmlUrl,
|
|
43
|
+
startedAt: faros_feeds_sdk_1.Utils.toDate(pipeline.createdOn),
|
|
44
|
+
endedAt: faros_feeds_sdk_1.Utils.toDate(pipeline.completedOn),
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
if ((_d = (_c = pipeline.target) === null || _c === void 0 ? void 0 : _c.commit) === null || _d === void 0 ? void 0 : _d.hash) {
|
|
48
|
+
const projectKey = {
|
|
49
|
+
name: repo.toLowerCase(),
|
|
50
|
+
organization: { uid: orgKey.uid, source },
|
|
51
|
+
};
|
|
52
|
+
res.push({
|
|
53
|
+
model: 'cicd_BuildCommitAssociation',
|
|
54
|
+
record: {
|
|
55
|
+
build: { uid: pipeline.uuid, pipeline: pipelineKey },
|
|
56
|
+
commit: { repository: projectKey, sha: pipeline.target.commit.hash },
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return res;
|
|
61
|
+
}
|
|
62
|
+
convertBuildStatus(state) {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
if (!state) {
|
|
65
|
+
return { category: 'Unknown', detail: 'undefined' };
|
|
66
|
+
}
|
|
67
|
+
// We're more interest in the "stage" than the "state" as this tells the true
|
|
68
|
+
// state of a pipeline build. The switch statement however takes care of all
|
|
69
|
+
// possible entries from both the "stage" and "state".
|
|
70
|
+
const detail = (_b = (((_a = state.stage) === null || _a === void 0 ? void 0 : _a.name) || state.name)) === null || _b === void 0 ? void 0 : _b.toLowerCase();
|
|
71
|
+
switch (detail) {
|
|
72
|
+
case 'error':
|
|
73
|
+
case 'failed':
|
|
74
|
+
return { category: BuildStatusCategory.FAILED, detail };
|
|
75
|
+
case 'in_progress':
|
|
76
|
+
case 'running':
|
|
77
|
+
return { category: BuildStatusCategory.RUNNING, detail };
|
|
78
|
+
case 'pending':
|
|
79
|
+
return { category: BuildStatusCategory.QUEUED, detail };
|
|
80
|
+
case 'stopped':
|
|
81
|
+
return { category: BuildStatusCategory.CANCELED, detail };
|
|
82
|
+
case 'completed':
|
|
83
|
+
case 'successful':
|
|
84
|
+
return { category: BuildStatusCategory.SUCCESS, detail };
|
|
85
|
+
default:
|
|
86
|
+
return { category: BuildStatusCategory.CUSTOM, detail };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.Pipelines = Pipelines;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AirbyteLogger, AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
|
|
3
|
+
import { BitbucketConverter } from './common';
|
|
4
|
+
import { PRActivity } from './types';
|
|
5
|
+
export declare class PullRequestActivities extends BitbucketConverter {
|
|
6
|
+
readonly logger: AirbyteLogger;
|
|
7
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
8
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
9
|
+
reviewState(prActivity: PRActivity): {
|
|
10
|
+
category: string;
|
|
11
|
+
detail: string | null;
|
|
12
|
+
} | undefined;
|
|
13
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PullRequestActivities = void 0;
|
|
4
|
+
const faros_airbyte_cdk_1 = require("faros-airbyte-cdk");
|
|
5
|
+
const faros_feeds_sdk_1 = require("faros-feeds-sdk");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
var PullRequestReviewStateCategory;
|
|
8
|
+
(function (PullRequestReviewStateCategory) {
|
|
9
|
+
PullRequestReviewStateCategory["APPROVED"] = "Approved";
|
|
10
|
+
PullRequestReviewStateCategory["COMMENTED"] = "Commented";
|
|
11
|
+
PullRequestReviewStateCategory["CHANGES_REQUESTS"] = "ChangesRequested";
|
|
12
|
+
PullRequestReviewStateCategory["DISMISSED"] = "Dismissed";
|
|
13
|
+
PullRequestReviewStateCategory["CUSTOM"] = "Custom";
|
|
14
|
+
})(PullRequestReviewStateCategory || (PullRequestReviewStateCategory = {}));
|
|
15
|
+
class PullRequestActivities extends common_1.BitbucketConverter {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.logger = new faros_airbyte_cdk_1.AirbyteLogger();
|
|
19
|
+
this.destinationModels = [
|
|
20
|
+
'vcs_User',
|
|
21
|
+
'vcs_PullRequestComment',
|
|
22
|
+
'vcs_PullRequestReview',
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
async convert(record, ctx) {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
27
|
+
const source = this.streamName.source;
|
|
28
|
+
const prActivity = record.record.data;
|
|
29
|
+
const res = [];
|
|
30
|
+
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.changesRequested) !== null && _c !== void 0 ? _c : prActivity === null || prActivity === void 0 ? void 0 : prActivity.update;
|
|
31
|
+
const date = faros_feeds_sdk_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);
|
|
32
|
+
const state = this.reviewState(prActivity);
|
|
33
|
+
if (!change || !state)
|
|
34
|
+
return res;
|
|
35
|
+
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();
|
|
36
|
+
if (!id) {
|
|
37
|
+
this.logger.debug(`Ignored activity for pull request ${prActivity.pullRequest.id} in repo ${prActivity.pullRequest.repositorySlug}, since it has no id: ${JSON.stringify(change)}`);
|
|
38
|
+
return res;
|
|
39
|
+
}
|
|
40
|
+
let reviewer = null;
|
|
41
|
+
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;
|
|
42
|
+
if (user === null || user === void 0 ? void 0 : user.accountId) {
|
|
43
|
+
const userRecord = common_1.BitbucketCommon.vcsUser(user, source);
|
|
44
|
+
if (userRecord) {
|
|
45
|
+
res.push(userRecord);
|
|
46
|
+
reviewer = { uid: user.accountId, source };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const orgRef = {
|
|
50
|
+
uid: (_j = (_h = prActivity === null || prActivity === void 0 ? void 0 : prActivity.pullRequest) === null || _h === void 0 ? void 0 : _h.workspace) === null || _j === void 0 ? void 0 : _j.toLowerCase(),
|
|
51
|
+
source,
|
|
52
|
+
};
|
|
53
|
+
const repoRef = {
|
|
54
|
+
name: (_l = (_k = prActivity === null || prActivity === void 0 ? void 0 : prActivity.pullRequest) === null || _k === void 0 ? void 0 : _k.repositorySlug) === null || _l === void 0 ? void 0 : _l.toLowerCase(),
|
|
55
|
+
organization: orgRef,
|
|
56
|
+
};
|
|
57
|
+
if (!orgRef.uid || repoRef.name) {
|
|
58
|
+
return res;
|
|
59
|
+
}
|
|
60
|
+
const pullRequest = {
|
|
61
|
+
repository: repoRef,
|
|
62
|
+
number: prActivity.pullRequest.id,
|
|
63
|
+
uid: prActivity.pullRequest.id.toString(),
|
|
64
|
+
};
|
|
65
|
+
if ((prActivity === null || prActivity === void 0 ? void 0 : prActivity.comment) && ((_m = prActivity === null || prActivity === void 0 ? void 0 : prActivity.comment) === null || _m === void 0 ? void 0 : _m.inline)) {
|
|
66
|
+
res.push({
|
|
67
|
+
model: 'vcs_PullRequestComment',
|
|
68
|
+
record: {
|
|
69
|
+
number: id,
|
|
70
|
+
uid: id.toString(),
|
|
71
|
+
comment: (_o = change === null || change === void 0 ? void 0 : change.content) === null || _o === void 0 ? void 0 : _o.raw,
|
|
72
|
+
createdAt: faros_feeds_sdk_1.Utils.toDate(change === null || change === void 0 ? void 0 : change.created_on),
|
|
73
|
+
updatedAt: faros_feeds_sdk_1.Utils.toDate(change === null || change === void 0 ? void 0 : change.updated_on),
|
|
74
|
+
author: reviewer,
|
|
75
|
+
pullRequest,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
res.push({
|
|
81
|
+
model: 'vcs_PullRequestReview',
|
|
82
|
+
record: {
|
|
83
|
+
number: id,
|
|
84
|
+
uid: id.toString(),
|
|
85
|
+
htmlUrl: (_r = (_q = (_p = change === null || change === void 0 ? void 0 : change.pull_request) === null || _p === void 0 ? void 0 : _p.links) === null || _q === void 0 ? void 0 : _q.html) === null || _r === void 0 ? void 0 : _r.href,
|
|
86
|
+
pullRequest,
|
|
87
|
+
reviewer,
|
|
88
|
+
state,
|
|
89
|
+
submittedAt: date,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return res;
|
|
94
|
+
}
|
|
95
|
+
reviewState(prActivity) {
|
|
96
|
+
var _a;
|
|
97
|
+
// We are only considering a subset of activities on the PR and ignoring everything else
|
|
98
|
+
if (prActivity === null || prActivity === void 0 ? void 0 : prActivity.comment)
|
|
99
|
+
return { category: PullRequestReviewStateCategory.COMMENTED, detail: null };
|
|
100
|
+
if (prActivity === null || prActivity === void 0 ? void 0 : prActivity.approval)
|
|
101
|
+
return { category: PullRequestReviewStateCategory.APPROVED, detail: null };
|
|
102
|
+
if (prActivity === null || prActivity === void 0 ? void 0 : prActivity.changesRequested)
|
|
103
|
+
return {
|
|
104
|
+
category: PullRequestReviewStateCategory.CHANGES_REQUESTS,
|
|
105
|
+
detail: null,
|
|
106
|
+
};
|
|
107
|
+
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')
|
|
108
|
+
return { category: PullRequestReviewStateCategory.DISMISSED, detail: null };
|
|
109
|
+
return { category: PullRequestReviewStateCategory.CUSTOM, detail: null };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.PullRequestActivities = PullRequestActivities;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext, StreamName } from '../converter';
|
|
3
|
+
import { BitbucketConverter } from './common';
|
|
4
|
+
export declare class PullRequests extends BitbucketConverter {
|
|
5
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
+
private readonly commitsStream;
|
|
7
|
+
get dependencies(): ReadonlyArray<StreamName>;
|
|
8
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
9
|
+
private toPrState;
|
|
10
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PullRequests = void 0;
|
|
4
|
+
const faros_feeds_sdk_1 = require("faros-feeds-sdk");
|
|
5
|
+
const converter_1 = require("../converter");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
var PullRequestStateCategory;
|
|
8
|
+
(function (PullRequestStateCategory) {
|
|
9
|
+
PullRequestStateCategory["CLOSED"] = "Closed";
|
|
10
|
+
PullRequestStateCategory["MERGED"] = "Merged";
|
|
11
|
+
PullRequestStateCategory["OPEN"] = "Open";
|
|
12
|
+
PullRequestStateCategory["CUSTOM"] = "Custom";
|
|
13
|
+
})(PullRequestStateCategory || (PullRequestStateCategory = {}));
|
|
14
|
+
class PullRequests extends common_1.BitbucketConverter {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.destinationModels = [
|
|
18
|
+
'vcs_User',
|
|
19
|
+
'vcs_PullRequest',
|
|
20
|
+
];
|
|
21
|
+
this.commitsStream = new converter_1.StreamName('bitbucket', 'commits');
|
|
22
|
+
}
|
|
23
|
+
get dependencies() {
|
|
24
|
+
return [this.commitsStream];
|
|
25
|
+
}
|
|
26
|
+
async convert(record, ctx) {
|
|
27
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
28
|
+
const source = this.streamName.source;
|
|
29
|
+
const pr = record.record.data;
|
|
30
|
+
const res = [];
|
|
31
|
+
const [workspace, repo] = (((_b = (_a = pr === null || pr === void 0 ? void 0 : pr.source) === null || _a === void 0 ? void 0 : _a.repository) === null || _b === void 0 ? void 0 : _b.fullName) ||
|
|
32
|
+
((_d = (_c = pr === null || pr === void 0 ? void 0 : pr.destination) === null || _c === void 0 ? void 0 : _c.repository) === null || _d === void 0 ? void 0 : _d.fullName) ||
|
|
33
|
+
'').split('/');
|
|
34
|
+
if (!workspace || !repo)
|
|
35
|
+
return res;
|
|
36
|
+
const repoRef = {
|
|
37
|
+
organization: { uid: workspace.toLowerCase(), source },
|
|
38
|
+
name: repo.toLowerCase(),
|
|
39
|
+
};
|
|
40
|
+
// Get full commit hash by fetching the commit by short hash
|
|
41
|
+
let mergeCommit = null;
|
|
42
|
+
const shortHash = (_e = pr === null || pr === void 0 ? void 0 : pr.mergeCommit) === null || _e === void 0 ? void 0 : _e.hash;
|
|
43
|
+
if (shortHash) {
|
|
44
|
+
const commitsStream = this.commitsStream.asString;
|
|
45
|
+
const commitRecords = ctx.getAll(commitsStream);
|
|
46
|
+
const commitHash = Object.keys(commitRecords).find((k) => k.startsWith(shortHash));
|
|
47
|
+
if (commitHash) {
|
|
48
|
+
mergeCommit = { repository: repoRef, sha: commitHash };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
let author = null;
|
|
52
|
+
if ((_f = pr === null || pr === void 0 ? void 0 : pr.author) === null || _f === void 0 ? void 0 : _f.accountId) {
|
|
53
|
+
const user = common_1.BitbucketCommon.vcsUser(pr.author, source);
|
|
54
|
+
if (!user)
|
|
55
|
+
return res;
|
|
56
|
+
res.push(user);
|
|
57
|
+
author = { uid: pr.author.accountId, source };
|
|
58
|
+
}
|
|
59
|
+
res.push({
|
|
60
|
+
model: 'vcs_PullRequest',
|
|
61
|
+
record: {
|
|
62
|
+
number: pr.id,
|
|
63
|
+
uid: pr.id.toString(),
|
|
64
|
+
title: pr.title,
|
|
65
|
+
state: this.toPrState(pr.state),
|
|
66
|
+
htmlUrl: (_g = pr === null || pr === void 0 ? void 0 : pr.links) === null || _g === void 0 ? void 0 : _g.htmlUrl,
|
|
67
|
+
createdAt: faros_feeds_sdk_1.Utils.toDate(pr.createdOn),
|
|
68
|
+
updatedAt: faros_feeds_sdk_1.Utils.toDate(pr.updatedOn),
|
|
69
|
+
mergedAt: faros_feeds_sdk_1.Utils.toDate((_h = pr.calculatedActivity) === null || _h === void 0 ? void 0 : _h.mergedAt),
|
|
70
|
+
commentCount: pr.commentCount,
|
|
71
|
+
commitCount: (_j = pr.calculatedActivity) === null || _j === void 0 ? void 0 : _j.commitCount,
|
|
72
|
+
diffStats: pr.diffStat,
|
|
73
|
+
author,
|
|
74
|
+
mergeCommit,
|
|
75
|
+
repository: repoRef,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
return res;
|
|
79
|
+
}
|
|
80
|
+
toPrState(state) {
|
|
81
|
+
const stateLower = state === null || state === void 0 ? void 0 : state.toLowerCase();
|
|
82
|
+
switch (stateLower) {
|
|
83
|
+
case 'open':
|
|
84
|
+
return { category: PullRequestStateCategory.OPEN, detail: stateLower };
|
|
85
|
+
case 'merged':
|
|
86
|
+
return { category: PullRequestStateCategory.MERGED, detail: stateLower };
|
|
87
|
+
case 'superseded':
|
|
88
|
+
case 'declined':
|
|
89
|
+
return { category: PullRequestStateCategory.CLOSED, detail: stateLower };
|
|
90
|
+
default:
|
|
91
|
+
return { category: PullRequestStateCategory.CUSTOM, detail: stateLower };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.PullRequests = PullRequests;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext, StreamName } from '../converter';
|
|
3
|
+
import { BitbucketConverter } from './common';
|
|
4
|
+
export declare class Repositories extends BitbucketConverter {
|
|
5
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
+
private readonly workspacesStream;
|
|
7
|
+
get dependencies(): ReadonlyArray<StreamName>;
|
|
8
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
9
|
+
}
|