airbyte-faros-destination 0.18.13 → 0.18.15
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/faros-event/cd_events.d.ts +14 -0
- package/lib/converters/faros-event/cd_events.js +175 -0
- package/lib/converters/faros-event/cd_events.js.map +1 -0
- package/lib/converters/faros-event/ci_events.d.ts +14 -0
- package/lib/converters/faros-event/ci_events.js +93 -0
- package/lib/converters/faros-event/ci_events.js.map +1 -0
- package/lib/converters/faros-event/common.d.ts +42 -0
- package/lib/converters/faros-event/common.js +343 -0
- package/lib/converters/faros-event/common.js.map +1 -0
- package/lib/converters/faros-event/types/cd.d.ts +2603 -0
- package/lib/converters/faros-event/types/cd.js +104 -0
- package/lib/converters/faros-event/types/cd.js.map +1 -0
- package/lib/converters/faros-event/types/ci.d.ts +1919 -0
- package/lib/converters/faros-event/types/ci.js +33 -0
- package/lib/converters/faros-event/types/ci.js.map +1 -0
- package/lib/converters/faros-event/types/common.d.ts +1134 -0
- package/lib/converters/faros-event/types/common.js +307 -0
- package/lib/converters/faros-event/types/common.js.map +1 -0
- package/lib/converters/faros-event/types/index.d.ts +22 -0
- package/lib/converters/faros-event/types/index.js +72 -0
- package/lib/converters/faros-event/types/index.js.map +1 -0
- package/lib/converters/faros-event/types/keys.d.ts +51 -0
- package/lib/converters/faros-event/types/keys.js +3 -0
- package/lib/converters/faros-event/types/keys.js.map +1 -0
- package/lib/converters/faros-event/types/params.d.ts +24 -0
- package/lib/converters/faros-event/types/params.js +15 -0
- package/lib/converters/faros-event/types/params.js.map +1 -0
- package/lib/converters/faros-event/utils.d.ts +113 -0
- package/lib/converters/faros-event/utils.js +388 -0
- package/lib/converters/faros-event/utils.js.map +1 -0
- package/lib/converters/notion/common.d.ts +24 -24
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationRecord, StreamContext } from '../converter';
|
|
3
|
+
import { FarosEventConverter } from './common';
|
|
4
|
+
import { CDEvent, Params } from './types';
|
|
5
|
+
interface CdEventArgs {
|
|
6
|
+
readonly data: CDEvent;
|
|
7
|
+
readonly params?: Params;
|
|
8
|
+
}
|
|
9
|
+
export declare class CdEvents extends FarosEventConverter {
|
|
10
|
+
readonly destinationModels: string[];
|
|
11
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<readonly DestinationRecord[]>;
|
|
12
|
+
}
|
|
13
|
+
export declare function handleCDEvent(args: CdEventArgs): DestinationRecord[];
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CdEvents = void 0;
|
|
4
|
+
exports.handleCDEvent = handleCDEvent;
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
const types_1 = require("./types");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
class CdEvents extends common_1.FarosEventConverter {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.destinationModels = [
|
|
12
|
+
'cicd_Agent',
|
|
13
|
+
'cicd_AgentTag',
|
|
14
|
+
'cicd_Artifact',
|
|
15
|
+
'cicd_ArtifactCommitAssociation',
|
|
16
|
+
'cicd_ArtifactDeployment',
|
|
17
|
+
'cicd_Build',
|
|
18
|
+
'cicd_BuildCommitAssociation',
|
|
19
|
+
'cicd_BuildMetric',
|
|
20
|
+
'cicd_BuildStep',
|
|
21
|
+
'cicd_BuildStepMetric',
|
|
22
|
+
'cicd_BuildStepTag',
|
|
23
|
+
'cicd_BuildTag',
|
|
24
|
+
'cicd_Deployment',
|
|
25
|
+
'cicd_DeploymentTag',
|
|
26
|
+
'cicd_Organization',
|
|
27
|
+
'cicd_Pipeline',
|
|
28
|
+
'cicd_Repository',
|
|
29
|
+
'compute_Application',
|
|
30
|
+
'compute_ApplicationPath',
|
|
31
|
+
'compute_ApplicationTag',
|
|
32
|
+
'compute_Instance',
|
|
33
|
+
'faros_MetricDefinition',
|
|
34
|
+
'faros_MetricValue',
|
|
35
|
+
'faros_Path',
|
|
36
|
+
'faros_Tag',
|
|
37
|
+
'vcs_Branch',
|
|
38
|
+
'vcs_BranchCommitAssociation',
|
|
39
|
+
'vcs_PullRequestCommit',
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
async convert(record, ctx) {
|
|
43
|
+
const data = record.record.data;
|
|
44
|
+
if ((0, types_1.validParams)(ctx.logger, data.params) &&
|
|
45
|
+
(0, types_1.validCDEvent)(ctx.logger, data.data)) {
|
|
46
|
+
return handleCDEvent(data);
|
|
47
|
+
}
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.CdEvents = CdEvents;
|
|
52
|
+
function handleCDEvent(args) {
|
|
53
|
+
const { data, params } = args;
|
|
54
|
+
const { skipSavingRun, noDeployUidPrefix } = params || {};
|
|
55
|
+
const records = [];
|
|
56
|
+
let buildKey;
|
|
57
|
+
if (data.run) {
|
|
58
|
+
const buildRes = (0, common_1.createBuildRecords)(data.run, skipSavingRun);
|
|
59
|
+
buildKey = buildRes.buildKey;
|
|
60
|
+
records.push(...buildRes.buildRecords);
|
|
61
|
+
}
|
|
62
|
+
let deploymentKey;
|
|
63
|
+
if (data.deploy) {
|
|
64
|
+
const deployRes = createDeployObjects(data.deploy, buildKey, noDeployUidPrefix);
|
|
65
|
+
deploymentKey = deployRes.deploymentKey;
|
|
66
|
+
records.push(...deployRes.deploymentRecords);
|
|
67
|
+
}
|
|
68
|
+
let artifactKey;
|
|
69
|
+
if (data.artifact) {
|
|
70
|
+
artifactKey = (0, common_1.createArtifact)(data.artifact);
|
|
71
|
+
}
|
|
72
|
+
if (data.commit) {
|
|
73
|
+
const { commitKey, commitRecords } = (0, common_1.createCommitObjects)(data.commit);
|
|
74
|
+
records.push(...commitRecords);
|
|
75
|
+
if (!artifactKey) {
|
|
76
|
+
// construct dummy artifact from commit
|
|
77
|
+
const artifactRes = (0, common_1.createArtifactRecords)((0, utils_1.makeDummyArtifact)(data.commit));
|
|
78
|
+
artifactKey = artifactRes.artifactKey;
|
|
79
|
+
records.push(...artifactRes.artifactRecords);
|
|
80
|
+
}
|
|
81
|
+
records.push({
|
|
82
|
+
model: 'cicd_ArtifactCommitAssociation',
|
|
83
|
+
record: { artifact: artifactKey, commit: commitKey },
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (deploymentKey && artifactKey) {
|
|
87
|
+
records.push({
|
|
88
|
+
model: 'cicd_ArtifactDeployment',
|
|
89
|
+
record: { artifact: artifactKey, deployment: deploymentKey },
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return records;
|
|
93
|
+
}
|
|
94
|
+
function createDeployObjects(deploy, buildKey, noDeployUidPrefix) {
|
|
95
|
+
var _a;
|
|
96
|
+
const deploymentRecords = [];
|
|
97
|
+
const deployIds = (0, utils_1.resolveDeploymentIds)(deploy);
|
|
98
|
+
const applicationKey = {
|
|
99
|
+
name: deployIds.application,
|
|
100
|
+
platform: (_a = deploy.applicationPlatform) !== null && _a !== void 0 ? _a : '',
|
|
101
|
+
};
|
|
102
|
+
deploymentRecords.push({
|
|
103
|
+
model: 'compute_Application',
|
|
104
|
+
record: applicationKey,
|
|
105
|
+
});
|
|
106
|
+
const applicationTags = (0, utils_1.parseTags)(deploy.applicationTags);
|
|
107
|
+
if (applicationTags === null || applicationTags === void 0 ? void 0 : applicationTags.length) {
|
|
108
|
+
const { tagKeys, tagRecords } = (0, common_1.createFarosTags)(applicationTags);
|
|
109
|
+
deploymentRecords.push(...tagRecords);
|
|
110
|
+
for (const tagKey of tagKeys) {
|
|
111
|
+
const compute_ApplicationTag = {
|
|
112
|
+
application: applicationKey,
|
|
113
|
+
tag: tagKey,
|
|
114
|
+
};
|
|
115
|
+
deploymentRecords.push({
|
|
116
|
+
model: 'compute_ApplicationTag',
|
|
117
|
+
record: compute_ApplicationTag,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const applicationPaths = (0, utils_1.parsePaths)(deploy.applicationPaths);
|
|
122
|
+
if (applicationPaths === null || applicationPaths === void 0 ? void 0 : applicationPaths.length) {
|
|
123
|
+
const paths = (0, common_1.createFarosPaths)(applicationPaths);
|
|
124
|
+
for (const faros_Path of paths) {
|
|
125
|
+
const compute_ApplicationPath = {
|
|
126
|
+
application: applicationKey,
|
|
127
|
+
path: faros_Path,
|
|
128
|
+
};
|
|
129
|
+
deploymentRecords.push({
|
|
130
|
+
model: 'faros_Path',
|
|
131
|
+
record: faros_Path,
|
|
132
|
+
});
|
|
133
|
+
deploymentRecords.push({
|
|
134
|
+
model: 'compute_ApplicationPath',
|
|
135
|
+
record: compute_ApplicationPath,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const deployment_uid_prefix = noDeployUidPrefix
|
|
140
|
+
? ''
|
|
141
|
+
: `${deployIds.application}__${deployIds.environment}__`;
|
|
142
|
+
const deploymentKey = {
|
|
143
|
+
uid: `${deployment_uid_prefix}${deployIds.id}`,
|
|
144
|
+
source: deployIds.source,
|
|
145
|
+
};
|
|
146
|
+
const cicd_Deployment = {
|
|
147
|
+
...deploymentKey,
|
|
148
|
+
url: deploy.url,
|
|
149
|
+
env: (0, utils_1.resolveDeploymentEnvironment)(deployIds.environment, (0, common_1.truncateStringOrNull)(deploy.environmentDetails)),
|
|
150
|
+
requestedAt: (0, utils_1.toDate)(deploy.requestedAt),
|
|
151
|
+
startedAt: (0, utils_1.toDate)(deploy.startTime),
|
|
152
|
+
endedAt: (0, utils_1.toDate)(deploy.endTime),
|
|
153
|
+
status: (0, utils_1.resolveDeploymentStatus)(deploy.status, (0, common_1.truncateStringOrNull)(deploy.statusDetails)),
|
|
154
|
+
application: applicationKey,
|
|
155
|
+
build: buildKey,
|
|
156
|
+
};
|
|
157
|
+
deploymentRecords.push({ model: 'cicd_Deployment', record: cicd_Deployment });
|
|
158
|
+
const deploymentTags = (0, utils_1.parseTags)(deploy.tags);
|
|
159
|
+
if (deploymentTags === null || deploymentTags === void 0 ? void 0 : deploymentTags.length) {
|
|
160
|
+
const { tagKeys, tagRecords } = (0, common_1.createFarosTags)(deploymentTags);
|
|
161
|
+
deploymentRecords.push(...tagRecords);
|
|
162
|
+
for (const tagKey of tagKeys) {
|
|
163
|
+
const cicd_DeploymentTag = {
|
|
164
|
+
deployment: deploymentKey,
|
|
165
|
+
tag: tagKey,
|
|
166
|
+
};
|
|
167
|
+
deploymentRecords.push({
|
|
168
|
+
model: 'cicd_DeploymentTag',
|
|
169
|
+
record: cicd_DeploymentTag,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return { deploymentKey, deploymentRecords };
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=cd_events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cd_events.js","sourceRoot":"","sources":["../../../src/converters/faros-event/cd_events.ts"],"names":[],"mappings":";;;AAuFA,sCAqDC;AAzID,qCAUkB;AAClB,mCASiB;AACjB,mCAQiB;AAOjB,MAAa,QAAS,SAAQ,4BAAmB;IAAjD;;QACW,sBAAiB,GAAG;YAC3B,YAAY;YACZ,eAAe;YACf,eAAe;YACf,gCAAgC;YAChC,yBAAyB;YACzB,YAAY;YACZ,6BAA6B;YAC7B,kBAAkB;YAClB,gBAAgB;YAChB,sBAAsB;YACtB,mBAAmB;YACnB,eAAe;YACf,iBAAiB;YACjB,oBAAoB;YACpB,mBAAmB;YACnB,eAAe;YACf,iBAAiB;YACjB,qBAAqB;YACrB,yBAAyB;YACzB,wBAAwB;YACxB,kBAAkB;YAClB,wBAAwB;YACxB,mBAAmB;YACnB,YAAY;YACZ,WAAW;YACX,YAAY;YACZ,6BAA6B;YAC7B,uBAAuB;SACxB,CAAC;IAgBJ,CAAC;IA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K,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,MAAM,kBAAkB,GAAG;gBACzB,UAAU,EAAE,aAAa;gBACzB,GAAG,EAAE,MAAM;aACZ,CAAC;YACF,iBAAiB,CAAC,IAAI,CAAC;gBACrB,KAAK,EAAE,oBAAoB;gBAC3B,MAAM,EAAE,kBAAkB;aAC3B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAC,aAAa,EAAE,iBAAiB,EAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationRecord, StreamContext } from '../converter';
|
|
3
|
+
import { FarosEventConverter } from './common';
|
|
4
|
+
import { CIEvent, Params } from './types';
|
|
5
|
+
interface CiEventArgs {
|
|
6
|
+
readonly data: CIEvent;
|
|
7
|
+
readonly params?: Params;
|
|
8
|
+
}
|
|
9
|
+
export declare class CiEvents extends FarosEventConverter {
|
|
10
|
+
readonly destinationModels: string[];
|
|
11
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<readonly DestinationRecord[]>;
|
|
12
|
+
}
|
|
13
|
+
export declare function handleCIEvent(args: CiEventArgs): DestinationRecord[];
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CiEvents = void 0;
|
|
4
|
+
exports.handleCIEvent = handleCIEvent;
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
const types_1 = require("./types");
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
class CiEvents extends common_1.FarosEventConverter {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.destinationModels = [
|
|
12
|
+
'cicd_Agent',
|
|
13
|
+
'cicd_AgentTag',
|
|
14
|
+
'cicd_Artifact',
|
|
15
|
+
'cicd_ArtifactCommitAssociation',
|
|
16
|
+
'cicd_Build',
|
|
17
|
+
'cicd_BuildCommitAssociation',
|
|
18
|
+
'cicd_BuildMetric',
|
|
19
|
+
'cicd_BuildStep',
|
|
20
|
+
'cicd_BuildStepMetric',
|
|
21
|
+
'cicd_BuildStepTag',
|
|
22
|
+
'cicd_BuildTag',
|
|
23
|
+
'cicd_Organization',
|
|
24
|
+
'cicd_Pipeline',
|
|
25
|
+
'cicd_Repository',
|
|
26
|
+
'compute_Instance',
|
|
27
|
+
'faros_MetricDefinition',
|
|
28
|
+
'faros_MetricValue',
|
|
29
|
+
'faros_Path',
|
|
30
|
+
'faros_Tag',
|
|
31
|
+
'vcs_Branch',
|
|
32
|
+
'vcs_BranchCommitAssociation',
|
|
33
|
+
'vcs_PullRequestCommit',
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
async convert(record, ctx) {
|
|
37
|
+
const data = record.record.data;
|
|
38
|
+
if ((0, types_1.validParams)(ctx.logger, data.params) &&
|
|
39
|
+
(0, types_1.validCIEvent)(ctx.logger, data.data)) {
|
|
40
|
+
return handleCIEvent(data);
|
|
41
|
+
}
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.CiEvents = CiEvents;
|
|
46
|
+
function handleCIEvent(args) {
|
|
47
|
+
const { data, params } = args;
|
|
48
|
+
const { skipSavingRun, noArtifact } = params || {};
|
|
49
|
+
const records = [];
|
|
50
|
+
let buildKey;
|
|
51
|
+
if (data.run) {
|
|
52
|
+
const buildRes = (0, common_1.createBuildRecords)(data.run, skipSavingRun);
|
|
53
|
+
buildKey = buildRes.buildKey;
|
|
54
|
+
records.push(...buildRes.buildRecords);
|
|
55
|
+
}
|
|
56
|
+
let commitKey;
|
|
57
|
+
if (data.commit) {
|
|
58
|
+
const commitRes = (0, common_1.createCommitObjects)(data.commit);
|
|
59
|
+
commitKey = commitRes.commitKey;
|
|
60
|
+
records.push(...commitRes.commitRecords);
|
|
61
|
+
if (buildKey) {
|
|
62
|
+
records.push({
|
|
63
|
+
model: 'cicd_BuildCommitAssociation',
|
|
64
|
+
record: { build: buildKey, commit: commitKey },
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
let artifactKey;
|
|
69
|
+
if (!noArtifact) {
|
|
70
|
+
if (data.artifact) {
|
|
71
|
+
const artifactRes = (0, common_1.createArtifactRecords)(data.artifact, buildKey);
|
|
72
|
+
artifactKey = artifactRes.artifactKey;
|
|
73
|
+
records.push(...artifactRes.artifactRecords);
|
|
74
|
+
}
|
|
75
|
+
else if (data.commit) {
|
|
76
|
+
// construct dummy artifact from commit
|
|
77
|
+
const dummyArtifactRes = (0, common_1.createArtifactRecords)((0, utils_1.makeDummyArtifact)(data.commit));
|
|
78
|
+
artifactKey = dummyArtifactRes.artifactKey;
|
|
79
|
+
records.push(...dummyArtifactRes.artifactRecords);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (commitKey && artifactKey) {
|
|
83
|
+
records.push({
|
|
84
|
+
model: 'cicd_ArtifactCommitAssociation',
|
|
85
|
+
record: {
|
|
86
|
+
artifact: artifactKey,
|
|
87
|
+
commit: commitKey,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return records;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=ci_events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ci_events.js","sourceRoot":"","sources":["../../../src/converters/faros-event/ci_events.ts"],"names":[],"mappings":";;;AAoEA,sCAqDC;AAtHD,qCAMkB;AAClB,mCAQiB;AACjB,mCAA0C;AAO1C,MAAa,QAAS,SAAQ,4BAAmB;IAAjD;;QACW,sBAAiB,GAAG;YAC3B,YAAY;YACZ,eAAe;YACf,eAAe;YACf,gCAAgC;YAChC,YAAY;YACZ,6BAA6B;YAC7B,kBAAkB;YAClB,gBAAgB;YAChB,sBAAsB;YACtB,mBAAmB;YACnB,eAAe;YAC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{ Agent, Artifact, cicd_Agent, cicd_Artifact, cicd_Build, Commit, faros_MetricValue, faros_Tag, FarosMetric, FarosPath, FarosTag, Run, vcs_Commit } from './types';
|
|
4
|
+
import { BuildIds } from './utils';
|
|
5
|
+
export type Maybe<T> = T | undefined;
|
|
6
|
+
export declare abstract class FarosEventConverter extends Converter {
|
|
7
|
+
id(record: AirbyteRecord): any;
|
|
8
|
+
source: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createArtifact(artifact: Artifact): cicd_Artifact;
|
|
11
|
+
export declare function createArtifactRecords(artifact: Artifact, build?: cicd_Build): {
|
|
12
|
+
artifactKey: cicd_Artifact;
|
|
13
|
+
artifactRecords: DestinationRecord[];
|
|
14
|
+
};
|
|
15
|
+
export declare function createCommitObjects(commit: Commit): {
|
|
16
|
+
commitKey: vcs_Commit;
|
|
17
|
+
commitRecords: DestinationRecord[];
|
|
18
|
+
};
|
|
19
|
+
export declare function createBuildRecords(run: Run, skipSavingRun?: boolean): {
|
|
20
|
+
buildKey: cicd_Build;
|
|
21
|
+
buildRecords: DestinationRecord[];
|
|
22
|
+
};
|
|
23
|
+
export declare function createAgentObjects(agent: Agent): {
|
|
24
|
+
agentKey: cicd_Agent;
|
|
25
|
+
agentRecords: DestinationRecord[];
|
|
26
|
+
};
|
|
27
|
+
export declare function createFarosMetricValues(metrics: FarosMetric[], valueUid: string): {
|
|
28
|
+
metricValueKeys: faros_MetricValue[];
|
|
29
|
+
metricRecords: DestinationRecord[];
|
|
30
|
+
};
|
|
31
|
+
export declare function createFarosTags(tags: FarosTag[]): {
|
|
32
|
+
tagKeys: faros_Tag[];
|
|
33
|
+
tagRecords: DestinationRecord[];
|
|
34
|
+
};
|
|
35
|
+
export declare function createFarosPaths(paths: FarosPath[]): {
|
|
36
|
+
uid: string;
|
|
37
|
+
path: string;
|
|
38
|
+
parts: string[];
|
|
39
|
+
}[];
|
|
40
|
+
export declare function buildIdsToString(buildIds: BuildIds): string;
|
|
41
|
+
export declare function buildStepIdsToString(buildIds: BuildIds, stepId: string): string;
|
|
42
|
+
export declare function truncateStringOrNull(str?: string): string | null;
|