airbyte-faros-destination 0.1.62 → 0.1.65
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 +2 -0
- package/lib/converters/azurepipeline/builds.d.ts +8 -0
- package/lib/converters/azurepipeline/builds.js +109 -0
- package/lib/converters/azurepipeline/common.d.ts +32 -0
- package/lib/converters/azurepipeline/common.js +119 -0
- package/lib/converters/azurepipeline/models.d.ts +298 -0
- package/lib/converters/azurepipeline/models.js +43 -0
- package/lib/converters/azurepipeline/pipelines.d.ts +8 -0
- package/lib/converters/azurepipeline/pipelines.js +68 -0
- package/lib/converters/azurepipeline/releases.d.ts +8 -0
- package/lib/converters/azurepipeline/releases.js +52 -0
- package/lib/converters/datadog/incidents.js +10 -9
- package/lib/converters/jenkins/builds.d.ts +2 -0
- package/lib/converters/jenkins/builds.js +66 -1
- package/lib/converters/jenkins/common.d.ts +6 -0
- package/lib/converters/jenkins/common.js +8 -1
- package/lib/converters/victorops/incidents.js +13 -13
- package/lib/destination.js +15 -11
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/resources/spec.json +21 -0
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ Each source stream is handled by an appropriate [Converter](https://github.com/f
|
|
|
6
6
|
|
|
7
7
|
Any additional source streams can be handled by providing a JSONata expression for the built-in [JSONataConverter](https://github.com/faros-ai/airbyte-connectors/tree/main/destinations/airbyte-faros-destination/src/converters/jsonata.ts) or by implementing converters for the streams ([read more below](#adding-support-for-additional-sources)).
|
|
8
8
|
|
|
9
|
+

|
|
10
|
+
|
|
9
11
|
## Usage
|
|
10
12
|
|
|
11
13
|
### Run from Airbyte
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
|
|
3
|
+
import { AzurePipelineConverter } from './common';
|
|
4
|
+
export declare class Builds extends AzurePipelineConverter {
|
|
5
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
+
private seenRepositories;
|
|
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.Builds = void 0;
|
|
4
|
+
const faros_feeds_sdk_1 = require("faros-feeds-sdk");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
class Builds extends common_1.AzurePipelineConverter {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.destinationModels = [
|
|
10
|
+
'cicd_Artifact',
|
|
11
|
+
'cicd_Build',
|
|
12
|
+
'cicd_BuildStep',
|
|
13
|
+
'cicd_Repository',
|
|
14
|
+
];
|
|
15
|
+
this.seenRepositories = new Set();
|
|
16
|
+
}
|
|
17
|
+
async convert(record, ctx) {
|
|
18
|
+
var _a;
|
|
19
|
+
const source = this.streamName.source;
|
|
20
|
+
const build = record.record.data;
|
|
21
|
+
const uid = String(build.id);
|
|
22
|
+
const organizationName = this.getOrganizationFromUrl(build.url);
|
|
23
|
+
const organization = { uid: organizationName, source };
|
|
24
|
+
const pipeline = {
|
|
25
|
+
uid: String((_a = build.definition) === null || _a === void 0 ? void 0 : _a.id),
|
|
26
|
+
organization: { uid: organizationName, source },
|
|
27
|
+
};
|
|
28
|
+
const buildUid = { uid, pipeline };
|
|
29
|
+
const createdAt = faros_feeds_sdk_1.Utils.toDate(build.queueTime);
|
|
30
|
+
const startedAt = faros_feeds_sdk_1.Utils.toDate(build.startTime);
|
|
31
|
+
const endedAt = faros_feeds_sdk_1.Utils.toDate(build.finishTime);
|
|
32
|
+
const status = this.convertBuildState(build.result);
|
|
33
|
+
const res = [];
|
|
34
|
+
const number = Number(build.buildNumber.replace('.', ''));
|
|
35
|
+
res.push({
|
|
36
|
+
model: 'cicd_Build',
|
|
37
|
+
record: {
|
|
38
|
+
uid,
|
|
39
|
+
name: build.buildNumber,
|
|
40
|
+
number,
|
|
41
|
+
createdAt,
|
|
42
|
+
startedAt,
|
|
43
|
+
endedAt,
|
|
44
|
+
status,
|
|
45
|
+
url: build.url,
|
|
46
|
+
pipeline,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
// TODO
|
|
50
|
+
const repo = build.repository;
|
|
51
|
+
if (!this.seenRepositories.has(repo.id)) {
|
|
52
|
+
this.seenRepositories.add(repo.id);
|
|
53
|
+
res.push({
|
|
54
|
+
model: 'cicd_Repository',
|
|
55
|
+
record: {
|
|
56
|
+
uid: repo.id,
|
|
57
|
+
name: repo.name,
|
|
58
|
+
description: null,
|
|
59
|
+
url: this.getRepoUrl(repo),
|
|
60
|
+
organization,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
for (const job of build.jobs) {
|
|
65
|
+
const jobCreatedAt = faros_feeds_sdk_1.Utils.toDate(job.startTime);
|
|
66
|
+
const jobStartedAt = faros_feeds_sdk_1.Utils.toDate(job.startTime);
|
|
67
|
+
const jobEndedAt = faros_feeds_sdk_1.Utils.toDate(job.finishTime);
|
|
68
|
+
const jobStatus = this.convertBuildStepState(job.result);
|
|
69
|
+
const jobType = this.convertBuildStepType(job.type);
|
|
70
|
+
res.push({
|
|
71
|
+
model: 'cicd_BuildStep',
|
|
72
|
+
record: {
|
|
73
|
+
uid: String(job.id),
|
|
74
|
+
name: job.name,
|
|
75
|
+
command: job.name,
|
|
76
|
+
type: jobType,
|
|
77
|
+
createdAt: jobCreatedAt,
|
|
78
|
+
startedAt: jobStartedAt,
|
|
79
|
+
endedAt: jobEndedAt,
|
|
80
|
+
status: jobStatus,
|
|
81
|
+
url: job.url,
|
|
82
|
+
build: buildUid,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
for (const artifact of build.artifacts) {
|
|
87
|
+
const artifactCreatedAt = faros_feeds_sdk_1.Utils.toDate(build.startTime);
|
|
88
|
+
const tags = [];
|
|
89
|
+
for (const [key, value] of Object.entries(artifact.resource.properties)) {
|
|
90
|
+
tags.push({ name: key, value: String(value) });
|
|
91
|
+
}
|
|
92
|
+
res.push({
|
|
93
|
+
model: 'cicd_Artifact',
|
|
94
|
+
record: {
|
|
95
|
+
uid: String(artifact.id),
|
|
96
|
+
name: artifact.name,
|
|
97
|
+
url: artifact.resource.url,
|
|
98
|
+
type: artifact.resource.type,
|
|
99
|
+
createdAt: artifactCreatedAt,
|
|
100
|
+
tags,
|
|
101
|
+
build: buildUid,
|
|
102
|
+
repository: { uid: repo.id, organization },
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return res;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.Builds = Builds;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { Converter, StreamContext } from '../converter';
|
|
3
|
+
import { BuildTimeline, DeploymentStatus, JobState, Repository, Timestamps } from './models';
|
|
4
|
+
export declare type ApplicationMapping = Record<string, {
|
|
5
|
+
name: string;
|
|
6
|
+
platform?: string;
|
|
7
|
+
}>;
|
|
8
|
+
interface AzurePipelineConfig {
|
|
9
|
+
application_mapping?: ApplicationMapping;
|
|
10
|
+
}
|
|
11
|
+
/** Azurepipeline converter base */
|
|
12
|
+
export declare abstract class AzurePipelineConverter extends Converter {
|
|
13
|
+
source: string;
|
|
14
|
+
/** Almost every Azurepipeline record have id property */
|
|
15
|
+
id(record: AirbyteRecord): any;
|
|
16
|
+
getOrganizationFromUrl(url: string): string;
|
|
17
|
+
protected azurepipleConfig(ctx: StreamContext): AzurePipelineConfig;
|
|
18
|
+
protected applicationMapping(ctx: StreamContext): ApplicationMapping;
|
|
19
|
+
convertBuildState(state: string | undefined): {
|
|
20
|
+
category: string;
|
|
21
|
+
detail: string;
|
|
22
|
+
};
|
|
23
|
+
getRepoUrl(repo: Repository): string | undefined;
|
|
24
|
+
convertBuildStepTime(buildStep: BuildTimeline): Timestamps;
|
|
25
|
+
convertBuildStepState(state: string | undefined): {
|
|
26
|
+
category: string;
|
|
27
|
+
detail: string;
|
|
28
|
+
};
|
|
29
|
+
convertBuildStepType(type: string): JobState;
|
|
30
|
+
convertDeploymentStatus(result: string): DeploymentStatus;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AzurePipelineConverter = void 0;
|
|
4
|
+
const faros_feeds_sdk_1 = require("faros-feeds-sdk");
|
|
5
|
+
const converter_1 = require("../converter");
|
|
6
|
+
const models_1 = require("./models");
|
|
7
|
+
/** Azurepipeline converter base */
|
|
8
|
+
class AzurePipelineConverter extends converter_1.Converter {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.source = 'AzurePipeline';
|
|
12
|
+
}
|
|
13
|
+
/** Almost every Azurepipeline record have id property */
|
|
14
|
+
id(record) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
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;
|
|
17
|
+
}
|
|
18
|
+
getOrganizationFromUrl(url) {
|
|
19
|
+
return url.split('/')[3];
|
|
20
|
+
}
|
|
21
|
+
azurepipleConfig(ctx) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
return (_b = (_a = ctx.config) === null || _a === void 0 ? void 0 : _a.source_specific_configs) === null || _b === void 0 ? void 0 : _b.azurepipeline;
|
|
24
|
+
}
|
|
25
|
+
applicationMapping(ctx) {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
return (_b = (_a = this.azurepipleConfig(ctx)) === null || _a === void 0 ? void 0 : _a.application_mapping) !== null && _b !== void 0 ? _b : {};
|
|
28
|
+
}
|
|
29
|
+
convertBuildState(state) {
|
|
30
|
+
if (!state) {
|
|
31
|
+
return { category: models_1.BuildStateCategory.Unknown, detail: 'undefined' };
|
|
32
|
+
}
|
|
33
|
+
const detail = state.toLowerCase();
|
|
34
|
+
// Read more on Azure pipeline build result:
|
|
35
|
+
// https://docs.microsoft.com/en-us/rest/api/azure/devops/build/builds/list?view=azure-devops-rest-6.0#buildresult
|
|
36
|
+
switch (detail) {
|
|
37
|
+
case 'canceled':
|
|
38
|
+
return { category: models_1.BuildStateCategory.Canceled, detail };
|
|
39
|
+
case 'failed':
|
|
40
|
+
return { category: models_1.BuildStateCategory.Failed, detail };
|
|
41
|
+
case 'succeeded':
|
|
42
|
+
case 'partiallySucceeded':
|
|
43
|
+
return { category: models_1.BuildStateCategory.Success, detail };
|
|
44
|
+
case 'running':
|
|
45
|
+
return { category: models_1.BuildStateCategory.Running, detail };
|
|
46
|
+
default:
|
|
47
|
+
return { category: models_1.BuildStateCategory.Custom, detail };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
getRepoUrl(repo) {
|
|
51
|
+
switch (repo.type) {
|
|
52
|
+
case 'Bitbucket':
|
|
53
|
+
return `https://bitbucket.org/${repo.id}`;
|
|
54
|
+
case 'GitHub':
|
|
55
|
+
case 'GitHubEnterprise':
|
|
56
|
+
return `https://github.com/${repo.id}`;
|
|
57
|
+
case 'GitLab':
|
|
58
|
+
return `https://gitlab.com/${repo.id}`;
|
|
59
|
+
case 'TfsGit':
|
|
60
|
+
return repo.url;
|
|
61
|
+
default:
|
|
62
|
+
return repo.url;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
convertBuildStepTime(buildStep) {
|
|
66
|
+
//const type = buildStep.type;
|
|
67
|
+
const result = {
|
|
68
|
+
createdAt: faros_feeds_sdk_1.Utils.toDate(buildStep.startTime),
|
|
69
|
+
startedAt: faros_feeds_sdk_1.Utils.toDate(buildStep.startTime),
|
|
70
|
+
endedAt: faros_feeds_sdk_1.Utils.toDate(buildStep.finishTime),
|
|
71
|
+
};
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
convertBuildStepState(state) {
|
|
75
|
+
if (!state) {
|
|
76
|
+
return { category: models_1.BuildStateCategory.Unknown, detail: 'undefined' };
|
|
77
|
+
}
|
|
78
|
+
const detail = state.toLowerCase();
|
|
79
|
+
//https://docs.microsoft.com/en-us/rest/api/azure/devops/build/timeline/get?view=azure-devops-rest-6.0#taskresult
|
|
80
|
+
switch (detail) {
|
|
81
|
+
case 'abandoned':
|
|
82
|
+
case 'canceled':
|
|
83
|
+
return { category: models_1.BuildStateCategory.Canceled, detail };
|
|
84
|
+
case 'failed':
|
|
85
|
+
case 'skipped':
|
|
86
|
+
return { category: models_1.BuildStateCategory.Failed, detail };
|
|
87
|
+
case 'succeeded':
|
|
88
|
+
return { category: models_1.BuildStateCategory.Success, detail };
|
|
89
|
+
case 'succeededWithIssues':
|
|
90
|
+
return { category: models_1.BuildStateCategory.Queued, detail };
|
|
91
|
+
default:
|
|
92
|
+
return { category: models_1.BuildStateCategory.Custom, detail };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// TODO
|
|
96
|
+
convertBuildStepType(type) {
|
|
97
|
+
if (!type) {
|
|
98
|
+
return { category: models_1.JobCategory.Custom, detail: 'undefined' };
|
|
99
|
+
}
|
|
100
|
+
return { category: models_1.JobCategory.Custom, detail: type };
|
|
101
|
+
}
|
|
102
|
+
convertDeploymentStatus(result) {
|
|
103
|
+
if (!result) {
|
|
104
|
+
return { category: models_1.DeploymentStatusCategory.Custom, detail: 'undefined' };
|
|
105
|
+
}
|
|
106
|
+
const detail = result;
|
|
107
|
+
switch (result) {
|
|
108
|
+
case 'canceled':
|
|
109
|
+
return { category: models_1.DeploymentStatusCategory.Canceled, detail };
|
|
110
|
+
case 'failed':
|
|
111
|
+
return { category: models_1.DeploymentStatusCategory.Failed, detail };
|
|
112
|
+
case 'succeeded':
|
|
113
|
+
return { category: models_1.DeploymentStatusCategory.Success, detail };
|
|
114
|
+
default:
|
|
115
|
+
return { category: models_1.DeploymentStatusCategory.Custom, detail };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
exports.AzurePipelineConverter = AzurePipelineConverter;
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
interface Href {
|
|
2
|
+
href: string;
|
|
3
|
+
}
|
|
4
|
+
interface PipelineLink {
|
|
5
|
+
self: Href;
|
|
6
|
+
web: Href;
|
|
7
|
+
}
|
|
8
|
+
interface RunLink {
|
|
9
|
+
self: Href;
|
|
10
|
+
web: Href;
|
|
11
|
+
pipeline: Href;
|
|
12
|
+
}
|
|
13
|
+
interface RunPipeline {
|
|
14
|
+
url: string;
|
|
15
|
+
id: number;
|
|
16
|
+
revision: number;
|
|
17
|
+
name: string;
|
|
18
|
+
folder: string;
|
|
19
|
+
}
|
|
20
|
+
interface Run {
|
|
21
|
+
_links: RunLink;
|
|
22
|
+
pipeline: RunPipeline;
|
|
23
|
+
state: string;
|
|
24
|
+
result: string;
|
|
25
|
+
createdDate: string;
|
|
26
|
+
finishedDate: string;
|
|
27
|
+
url: string;
|
|
28
|
+
id: number;
|
|
29
|
+
name: string;
|
|
30
|
+
}
|
|
31
|
+
export interface Pipeline {
|
|
32
|
+
id: number;
|
|
33
|
+
revision: number;
|
|
34
|
+
name?: string;
|
|
35
|
+
url?: string;
|
|
36
|
+
folder?: string;
|
|
37
|
+
_links: PipelineLink;
|
|
38
|
+
runs: Run[];
|
|
39
|
+
}
|
|
40
|
+
interface BuildLink {
|
|
41
|
+
self: Href;
|
|
42
|
+
web: Href;
|
|
43
|
+
sourceVersionDisplayUri: Href;
|
|
44
|
+
timeline: Href;
|
|
45
|
+
badge: Href;
|
|
46
|
+
}
|
|
47
|
+
interface BuildPlan {
|
|
48
|
+
planId: string;
|
|
49
|
+
}
|
|
50
|
+
interface BuildDefinitionProject {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
description: string;
|
|
54
|
+
url: string;
|
|
55
|
+
state: string;
|
|
56
|
+
revision: number;
|
|
57
|
+
visibility: string;
|
|
58
|
+
lastUpdateTime: string;
|
|
59
|
+
}
|
|
60
|
+
interface BuildDefinition {
|
|
61
|
+
drafts: any[];
|
|
62
|
+
id: number;
|
|
63
|
+
name: string;
|
|
64
|
+
url: string;
|
|
65
|
+
uri: string;
|
|
66
|
+
path: string;
|
|
67
|
+
type: string;
|
|
68
|
+
queueStatus: string;
|
|
69
|
+
revision: number;
|
|
70
|
+
project: BuildDefinitionProject;
|
|
71
|
+
}
|
|
72
|
+
interface BuildQueuePool {
|
|
73
|
+
id: number;
|
|
74
|
+
name: string;
|
|
75
|
+
isHosted: boolean;
|
|
76
|
+
}
|
|
77
|
+
interface BuildQueue {
|
|
78
|
+
id: number;
|
|
79
|
+
name: string;
|
|
80
|
+
pool: BuildQueuePool;
|
|
81
|
+
}
|
|
82
|
+
interface BuildRequestLinkAvatar {
|
|
83
|
+
avatar: Href;
|
|
84
|
+
}
|
|
85
|
+
interface BuildRequestLink {
|
|
86
|
+
avatar: BuildRequestLinkAvatar;
|
|
87
|
+
}
|
|
88
|
+
interface BuildRequest {
|
|
89
|
+
displayName: string;
|
|
90
|
+
url: string;
|
|
91
|
+
id: string;
|
|
92
|
+
uniqueName: string;
|
|
93
|
+
imageUrl: string;
|
|
94
|
+
descriptor: string;
|
|
95
|
+
_link: BuildRequestLink;
|
|
96
|
+
}
|
|
97
|
+
interface BuildLog {
|
|
98
|
+
id: number;
|
|
99
|
+
type: string;
|
|
100
|
+
url: string;
|
|
101
|
+
}
|
|
102
|
+
export interface Repository {
|
|
103
|
+
id: string;
|
|
104
|
+
type: string;
|
|
105
|
+
name: string;
|
|
106
|
+
url: string;
|
|
107
|
+
clean?: string;
|
|
108
|
+
checkoutSubmodules: boolean;
|
|
109
|
+
}
|
|
110
|
+
interface ArtifactResource {
|
|
111
|
+
data: string;
|
|
112
|
+
downloadUrl: string;
|
|
113
|
+
properties: any;
|
|
114
|
+
type: string;
|
|
115
|
+
url: string;
|
|
116
|
+
_links: any;
|
|
117
|
+
}
|
|
118
|
+
interface BuildArtifact {
|
|
119
|
+
id: number;
|
|
120
|
+
name: string;
|
|
121
|
+
resource: ArtifactResource;
|
|
122
|
+
source: string;
|
|
123
|
+
}
|
|
124
|
+
interface BuildTimelineIssue {
|
|
125
|
+
type: string;
|
|
126
|
+
category?: any;
|
|
127
|
+
message: string;
|
|
128
|
+
}
|
|
129
|
+
export interface BuildTimeline {
|
|
130
|
+
previousAttempts: any[];
|
|
131
|
+
id: string;
|
|
132
|
+
parentId: string;
|
|
133
|
+
type: string;
|
|
134
|
+
name: string;
|
|
135
|
+
startTime?: any;
|
|
136
|
+
finishTime?: any;
|
|
137
|
+
currentOperation?: any;
|
|
138
|
+
percentComplete?: any;
|
|
139
|
+
state: string;
|
|
140
|
+
result: string;
|
|
141
|
+
resultCode?: any;
|
|
142
|
+
changeId: number;
|
|
143
|
+
lastModified: Date;
|
|
144
|
+
workerName?: any;
|
|
145
|
+
queueId: number;
|
|
146
|
+
order: number;
|
|
147
|
+
details?: any;
|
|
148
|
+
errorCount: number;
|
|
149
|
+
warningCount: number;
|
|
150
|
+
url?: any;
|
|
151
|
+
log?: any;
|
|
152
|
+
task?: any;
|
|
153
|
+
attempt: number;
|
|
154
|
+
identifier: string;
|
|
155
|
+
issues: BuildTimelineIssue[];
|
|
156
|
+
}
|
|
157
|
+
export interface Build {
|
|
158
|
+
_links: BuildLink;
|
|
159
|
+
properties: any;
|
|
160
|
+
tags: any[];
|
|
161
|
+
validationResults: any[];
|
|
162
|
+
plans: BuildPlan[];
|
|
163
|
+
triggerInfo: any;
|
|
164
|
+
id: number;
|
|
165
|
+
buildNumber: string;
|
|
166
|
+
status: string;
|
|
167
|
+
result: string;
|
|
168
|
+
queueTime: string;
|
|
169
|
+
startTime: string;
|
|
170
|
+
finishTime: string;
|
|
171
|
+
url: string;
|
|
172
|
+
definition: BuildDefinition;
|
|
173
|
+
buildNumberRevision: number;
|
|
174
|
+
project: BuildDefinitionProject;
|
|
175
|
+
uri: string;
|
|
176
|
+
sourceBranch: string;
|
|
177
|
+
sourceVersion: string;
|
|
178
|
+
queue: BuildQueue;
|
|
179
|
+
priority: string;
|
|
180
|
+
reason: string;
|
|
181
|
+
requestedFor: BuildRequest;
|
|
182
|
+
requestedBy: BuildRequest;
|
|
183
|
+
lastChangedDate: string;
|
|
184
|
+
lastChangedBy: BuildRequest;
|
|
185
|
+
orchestrationPlan: BuildPlan;
|
|
186
|
+
logs: BuildLog;
|
|
187
|
+
repository: Repository;
|
|
188
|
+
keepForever: boolean;
|
|
189
|
+
retainedByRelease: boolean;
|
|
190
|
+
triggeredByBuild: any;
|
|
191
|
+
artifacts: BuildArtifact[];
|
|
192
|
+
jobs: BuildTimeline[];
|
|
193
|
+
}
|
|
194
|
+
interface ReleaseByUser {
|
|
195
|
+
id: string;
|
|
196
|
+
displayName: string;
|
|
197
|
+
uniqueName: string;
|
|
198
|
+
url: string;
|
|
199
|
+
imageUrl?: string;
|
|
200
|
+
}
|
|
201
|
+
interface ReleaseLink {
|
|
202
|
+
self: Href;
|
|
203
|
+
web: Href;
|
|
204
|
+
}
|
|
205
|
+
interface ReleaseProjectReference {
|
|
206
|
+
id: string;
|
|
207
|
+
name: string;
|
|
208
|
+
}
|
|
209
|
+
export interface Release {
|
|
210
|
+
id: number;
|
|
211
|
+
name: string;
|
|
212
|
+
status: string;
|
|
213
|
+
createdOn: string;
|
|
214
|
+
modifiedOn?: string;
|
|
215
|
+
modifiedBy?: ReleaseByUser;
|
|
216
|
+
createdBy: ReleaseByUser;
|
|
217
|
+
variables: any;
|
|
218
|
+
variableGroups: [any];
|
|
219
|
+
description?: string;
|
|
220
|
+
reason?: string;
|
|
221
|
+
releaseNameFormat?: string;
|
|
222
|
+
keepForever: boolean;
|
|
223
|
+
definitionSnapshotRevision: number;
|
|
224
|
+
logsContainerUrl: string;
|
|
225
|
+
url: string;
|
|
226
|
+
_links: ReleaseLink;
|
|
227
|
+
tags: [any];
|
|
228
|
+
projectReference: ReleaseProjectReference;
|
|
229
|
+
properties: any;
|
|
230
|
+
}
|
|
231
|
+
export declare enum RepoSource {
|
|
232
|
+
BITBUCKET = "Bitbucket",
|
|
233
|
+
GITHUB = "GitHub",
|
|
234
|
+
GITLAB = "GitLab",
|
|
235
|
+
VCS = "VCS"
|
|
236
|
+
}
|
|
237
|
+
export declare enum BuildStateCategory {
|
|
238
|
+
Unknown = "Unknown",
|
|
239
|
+
Canceled = "Canceled",
|
|
240
|
+
Failed = "Failed",
|
|
241
|
+
Success = "Success",
|
|
242
|
+
Running = "Running",
|
|
243
|
+
Queued = "Queued",
|
|
244
|
+
Custom = "Custom"
|
|
245
|
+
}
|
|
246
|
+
export declare enum JobCategory {
|
|
247
|
+
Custom = "Custom",
|
|
248
|
+
Script = "Script",
|
|
249
|
+
Manual = "Manual"
|
|
250
|
+
}
|
|
251
|
+
export interface Repo {
|
|
252
|
+
readonly provider: Provider;
|
|
253
|
+
readonly url: string;
|
|
254
|
+
}
|
|
255
|
+
export interface RepoExtract {
|
|
256
|
+
readonly org: string;
|
|
257
|
+
readonly name: string;
|
|
258
|
+
}
|
|
259
|
+
export interface Provider {
|
|
260
|
+
readonly name: RepoSource;
|
|
261
|
+
}
|
|
262
|
+
export interface Timestamps {
|
|
263
|
+
createdAt?: Date;
|
|
264
|
+
startedAt?: Date;
|
|
265
|
+
endedAt?: Date;
|
|
266
|
+
}
|
|
267
|
+
export interface JobState {
|
|
268
|
+
category: string;
|
|
269
|
+
detail: string;
|
|
270
|
+
}
|
|
271
|
+
export interface Tag {
|
|
272
|
+
readonly name: string;
|
|
273
|
+
readonly value: string;
|
|
274
|
+
}
|
|
275
|
+
export declare enum UserTypeCategory {
|
|
276
|
+
BOT = "Bot",
|
|
277
|
+
ORGANIZATION = "Organization",
|
|
278
|
+
USER = "User",
|
|
279
|
+
CUSTOM = "Custom"
|
|
280
|
+
}
|
|
281
|
+
export declare enum DeploymentStatusCategory {
|
|
282
|
+
Canceled = "Canceled",
|
|
283
|
+
Custom = "Custom",
|
|
284
|
+
Failed = "Failed",
|
|
285
|
+
Queued = "Queued",
|
|
286
|
+
Running = "Running",
|
|
287
|
+
RolledBack = "RolledBack",
|
|
288
|
+
Success = "Success"
|
|
289
|
+
}
|
|
290
|
+
export interface DeploymentStatus {
|
|
291
|
+
category: DeploymentStatusCategory;
|
|
292
|
+
detail: string;
|
|
293
|
+
}
|
|
294
|
+
export interface ComputeApplication {
|
|
295
|
+
name: string;
|
|
296
|
+
platform: string;
|
|
297
|
+
}
|
|
298
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeploymentStatusCategory = exports.UserTypeCategory = exports.JobCategory = exports.BuildStateCategory = exports.RepoSource = void 0;
|
|
4
|
+
var RepoSource;
|
|
5
|
+
(function (RepoSource) {
|
|
6
|
+
RepoSource["BITBUCKET"] = "Bitbucket";
|
|
7
|
+
RepoSource["GITHUB"] = "GitHub";
|
|
8
|
+
RepoSource["GITLAB"] = "GitLab";
|
|
9
|
+
RepoSource["VCS"] = "VCS";
|
|
10
|
+
})(RepoSource = exports.RepoSource || (exports.RepoSource = {}));
|
|
11
|
+
var BuildStateCategory;
|
|
12
|
+
(function (BuildStateCategory) {
|
|
13
|
+
BuildStateCategory["Unknown"] = "Unknown";
|
|
14
|
+
BuildStateCategory["Canceled"] = "Canceled";
|
|
15
|
+
BuildStateCategory["Failed"] = "Failed";
|
|
16
|
+
BuildStateCategory["Success"] = "Success";
|
|
17
|
+
BuildStateCategory["Running"] = "Running";
|
|
18
|
+
BuildStateCategory["Queued"] = "Queued";
|
|
19
|
+
BuildStateCategory["Custom"] = "Custom";
|
|
20
|
+
})(BuildStateCategory = exports.BuildStateCategory || (exports.BuildStateCategory = {}));
|
|
21
|
+
var JobCategory;
|
|
22
|
+
(function (JobCategory) {
|
|
23
|
+
JobCategory["Custom"] = "Custom";
|
|
24
|
+
JobCategory["Script"] = "Script";
|
|
25
|
+
JobCategory["Manual"] = "Manual";
|
|
26
|
+
})(JobCategory = exports.JobCategory || (exports.JobCategory = {}));
|
|
27
|
+
var UserTypeCategory;
|
|
28
|
+
(function (UserTypeCategory) {
|
|
29
|
+
UserTypeCategory["BOT"] = "Bot";
|
|
30
|
+
UserTypeCategory["ORGANIZATION"] = "Organization";
|
|
31
|
+
UserTypeCategory["USER"] = "User";
|
|
32
|
+
UserTypeCategory["CUSTOM"] = "Custom";
|
|
33
|
+
})(UserTypeCategory = exports.UserTypeCategory || (exports.UserTypeCategory = {}));
|
|
34
|
+
var DeploymentStatusCategory;
|
|
35
|
+
(function (DeploymentStatusCategory) {
|
|
36
|
+
DeploymentStatusCategory["Canceled"] = "Canceled";
|
|
37
|
+
DeploymentStatusCategory["Custom"] = "Custom";
|
|
38
|
+
DeploymentStatusCategory["Failed"] = "Failed";
|
|
39
|
+
DeploymentStatusCategory["Queued"] = "Queued";
|
|
40
|
+
DeploymentStatusCategory["Running"] = "Running";
|
|
41
|
+
DeploymentStatusCategory["RolledBack"] = "RolledBack";
|
|
42
|
+
DeploymentStatusCategory["Success"] = "Success";
|
|
43
|
+
})(DeploymentStatusCategory = exports.DeploymentStatusCategory || (exports.DeploymentStatusCategory = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
|
|
3
|
+
import { AzurePipelineConverter } from './common';
|
|
4
|
+
export declare class Pipelines extends AzurePipelineConverter {
|
|
5
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
+
private seenOrganizations;
|
|
7
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pipelines = void 0;
|
|
4
|
+
const lib_1 = require("faros-feeds-sdk/lib");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
class Pipelines extends common_1.AzurePipelineConverter {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.destinationModels = [
|
|
10
|
+
'cicd_Deployment',
|
|
11
|
+
'cicd_Organization',
|
|
12
|
+
'cicd_Pipeline',
|
|
13
|
+
];
|
|
14
|
+
this.seenOrganizations = new Set();
|
|
15
|
+
}
|
|
16
|
+
async convert(record, ctx) {
|
|
17
|
+
var _a;
|
|
18
|
+
const source = this.streamName.source;
|
|
19
|
+
const pipeline = record.record.data;
|
|
20
|
+
const res = [];
|
|
21
|
+
const organizationName = this.getOrganizationFromUrl(pipeline.url);
|
|
22
|
+
const organization = { uid: organizationName, source };
|
|
23
|
+
if (!this.seenOrganizations.has(organizationName)) {
|
|
24
|
+
this.seenOrganizations.add(organizationName);
|
|
25
|
+
res.push({
|
|
26
|
+
model: 'cicd_Organization',
|
|
27
|
+
record: {
|
|
28
|
+
uid: organizationName,
|
|
29
|
+
name: organizationName,
|
|
30
|
+
source,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
for (const runItem of pipeline.runs) {
|
|
35
|
+
const applicationMapping = this.applicationMapping(ctx);
|
|
36
|
+
const application = (_a = (applicationMapping && applicationMapping[runItem.name])) !== null && _a !== void 0 ? _a : null;
|
|
37
|
+
const startedAt = lib_1.Utils.toDate(runItem.createdDate);
|
|
38
|
+
const endedAt = lib_1.Utils.toDate(runItem.finishedDate);
|
|
39
|
+
const status = this.convertDeploymentStatus(runItem.result);
|
|
40
|
+
res.push({
|
|
41
|
+
model: 'cicd_Deployment',
|
|
42
|
+
record: {
|
|
43
|
+
uid: String(runItem.id),
|
|
44
|
+
application,
|
|
45
|
+
build: {
|
|
46
|
+
uid: String(runItem.id),
|
|
47
|
+
pipeline: { uid: String(pipeline.id), organization },
|
|
48
|
+
},
|
|
49
|
+
startedAt,
|
|
50
|
+
endedAt,
|
|
51
|
+
status,
|
|
52
|
+
source,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
res.push({
|
|
57
|
+
model: 'cicd_Pipeline',
|
|
58
|
+
record: {
|
|
59
|
+
uid: String(pipeline.id),
|
|
60
|
+
name: pipeline.name,
|
|
61
|
+
url: pipeline.url,
|
|
62
|
+
organization,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
return res;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.Pipelines = Pipelines;
|