bitrise-api-cli 0.0.11 → 0.0.12

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.
@@ -1,1696 +0,0 @@
1
- import {
2
- validArtifactTypes
3
- } from "./chunk-CF25N4TY.js";
4
-
5
- // src/bitrise/env.ts
6
- var ENV = {
7
- debug: false,
8
- appSlug: "",
9
- token: "",
10
- workflow: "",
11
- artifactType: "android-apk"
12
- };
13
- var saveOptions = (options) => {
14
- ENV.debug = options.debug;
15
- ENV.appSlug = options.slug;
16
- ENV.token = options.token;
17
- ENV.workflow = options.workflow;
18
- ENV.artifactType = options.artifact;
19
- };
20
- var isEnvValid = () => {
21
- if (ENV.appSlug.length < 1) {
22
- console.log("No app slug provided! (see --help for more information)");
23
- return false;
24
- }
25
- if (ENV.token?.length < 1) {
26
- console.log("No token provided! (see --help for more information)");
27
- return false;
28
- }
29
- if (ENV.workflow?.length < 1) {
30
- console.log("No workflow provided! (see --help for more information)");
31
- return false;
32
- }
33
- if (!validArtifactTypes.includes(ENV.artifactType)) {
34
- console.log(`Invalid artifact type "${ENV.artifactType}"! (see --help for more information)`);
35
- return false;
36
- }
37
- return true;
38
- };
39
- var setupEnv = (flags) => {
40
- if (flags.debug) console.log(JSON.stringify(flags, null, 2));
41
- saveOptions(flags);
42
- return isEnvValid();
43
- };
44
-
45
- // src/device/install/android.ts
46
- import { $ } from "zx";
47
- var adbPath = `${process.env.ANDROID_HOME}/platform-tools/adb`;
48
- var installApk = async (apkPath) => {
49
- const { duration } = await $`${adbPath} install -r -d ${apkPath}`;
50
- return { duration };
51
- };
52
- var installSplitApk = async (apkFolder) => {
53
- const { duration } = await $`${adbPath} install-multiple -r -d ${apkFolder}/*`;
54
- return { duration };
55
- };
56
-
57
- // src/device/install/convertAabToApk.ts
58
- import fs3 from "node:fs/promises";
59
- import path3 from "node:path";
60
-
61
- // src/device/install/bundletool.ts
62
- import fs2 from "node:fs/promises";
63
- import path2 from "node:path";
64
-
65
- // src/helper/formatTime.ts
66
- var formatTime = (timeMs) => {
67
- if (timeMs < 1e3) return `${timeMs}ms`;
68
- return `${(timeMs / 1e3).toFixed(1)}s`;
69
- };
70
-
71
- // src/helper/typeHelper.ts
72
- var isFetchError = (e) => {
73
- if (typeof e !== "object" || !e) return false;
74
- return "response" in e && typeof e.response === "object" && !!e.response && "status" in e.response && "statusText" in e.response;
75
- };
76
-
77
- // src/helper/oraHelper.ts
78
- var getOraTexts = (label) => ({
79
- text: label,
80
- failText: (error) => {
81
- if (isFetchError(error))
82
- return `${label} failed with HTTP Error ${error.response.status} ${error.response.statusText}`;
83
- return `${label} failed with error: ${error.message}`;
84
- },
85
- successText: (data) => {
86
- if (data && typeof data === "object" && "duration" in data && typeof data.duration === "number") {
87
- return `${label} [took ${formatTime(data.duration)}]`;
88
- }
89
- return label;
90
- }
91
- });
92
-
93
- // src/helper/tempDir.ts
94
- import fs from "node:fs/promises";
95
- import { tmpdir } from "node:os";
96
- import path from "node:path";
97
- var createTempDir = async (name, suffix = `${Date.now()}`) => {
98
- const tmpDir = path.join(tmpdir(), `${name}-${suffix}`);
99
- await fs.mkdir(tmpDir, { recursive: true });
100
- return tmpDir;
101
- };
102
-
103
- // src/helper/tryCatch.ts
104
- async function tryCatch(promise) {
105
- try {
106
- const data = await promise;
107
- return { data, error: null };
108
- } catch (error) {
109
- return { data: null, error };
110
- }
111
- }
112
-
113
- // src/device/install/bundletool.ts
114
- import { oraPromise } from "ora";
115
- import { $ as $2, which } from "zx";
116
- var getOrInstallBundletool = async () => {
117
- const bundletoolPath = await which("bundletool", { nothrow: true });
118
- if (bundletoolPath) return { type: "global", path: bundletoolPath };
119
- const jarInfo = await getBundleToolJar();
120
- if (jarInfo) return jarInfo;
121
- return oraPromise(installBundleTool(), getOraTexts("Downloading bundletool"));
122
- };
123
- var bundletoolVersion = "1.18.1";
124
- var bundletoolData = {
125
- version: bundletoolVersion,
126
- filename: `bundletool-all-${bundletoolVersion}.jar`,
127
- url: `https://github.com/google/bundletool/releases/download/${bundletoolVersion}/bundletool-all-${bundletoolVersion}.jar`
128
- };
129
- var getBundletoolTmpJarPath = async () => {
130
- const bundletoolPath = await createTempDir("bitrise-api-cli", "bundletool");
131
- return path2.join(bundletoolPath, bundletoolData.filename);
132
- };
133
- var $$ = $2({ quiet: true });
134
- var getBundleToolJar = async () => {
135
- const jarPath = await getBundletoolTmpJarPath();
136
- const { error } = await tryCatch(fs2.access(jarPath));
137
- if (!error) return { type: "jar", path: jarPath };
138
- return false;
139
- };
140
- var installBundleTool = async () => {
141
- const jarPath = await getBundletoolTmpJarPath();
142
- const { duration } = await $$`curl -L ${bundletoolData.url} -o ${jarPath}`;
143
- await $2`java -jar ${jarPath} version`;
144
- return { type: "jar", path: jarPath, duration };
145
- };
146
-
147
- // src/device/install/convertAabToApk.ts
148
- import { $ as $3 } from "zx";
149
- var convertAabToApk = async (aabPath, flags) => {
150
- const startTime = Date.now();
151
- const tempDir = await createTempDir("bitrise-api-cli");
152
- const fileName = path3.basename(aabPath, ".aab");
153
- const outPath = path3.join(tempDir, `${fileName}.apks`);
154
- const zipPath = path3.join(tempDir, `${fileName}.zip`);
155
- const bundletool = await getOrInstallBundletool();
156
- if (flags.debug) console.log(`bundletool installation type: ${bundletool.type} in path ${bundletool.path}`);
157
- if (bundletool.type === "global") {
158
- await $3`bundletool build-apks --connected-device --bundle=${fileName}.aab --output=${outPath}`;
159
- } else if (bundletool.type === "jar") {
160
- await $3`java -jar ${bundletool.path} build-apks --connected-device --bundle=${fileName}.aab --output=${outPath}`;
161
- }
162
- await fs3.rename(outPath, zipPath);
163
- await $3`unzip -o ${zipPath} -d ${tempDir}`;
164
- return { apkFolder: path3.join(tempDir, "./splits"), duration: Date.now() - startTime };
165
- };
166
-
167
- // src/device/install/run.ts
168
- import { oraPromise as oraPromise2 } from "ora";
169
- var installApp = async ({ file, flags }) => {
170
- if (flags.artifact === "android-apk" && file.endsWith(".aab")) {
171
- const { apkFolder } = await oraPromise2(convertAabToApk(file, flags), getOraTexts("Convert AAB to Split APK"));
172
- await oraPromise2(installSplitApk(apkFolder), getOraTexts("installing Split APK"));
173
- } else if (flags.artifact === "android-apk" && file.endsWith(".apk")) {
174
- await oraPromise2(installApk(file), getOraTexts("installing APK"));
175
- } else if (flags.artifact === "android-apk") {
176
- throw Error("Artifact is not an APK or AAB file");
177
- } else {
178
- return console.log("Installing on iOS is not supported yet");
179
- }
180
- };
181
-
182
- // src/generated_api/runtime.ts
183
- var BASE_PATH = "https://api.bitrise.io/v0.1".replace(/\/+$/, "");
184
- var Configuration = class {
185
- constructor(configuration = {}) {
186
- this.configuration = configuration;
187
- }
188
- set config(configuration) {
189
- this.configuration = configuration;
190
- }
191
- get basePath() {
192
- return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
193
- }
194
- get fetchApi() {
195
- return this.configuration.fetchApi;
196
- }
197
- get middleware() {
198
- return this.configuration.middleware || [];
199
- }
200
- get queryParamsStringify() {
201
- return this.configuration.queryParamsStringify || querystring;
202
- }
203
- get username() {
204
- return this.configuration.username;
205
- }
206
- get password() {
207
- return this.configuration.password;
208
- }
209
- get apiKey() {
210
- const apiKey = this.configuration.apiKey;
211
- if (apiKey) {
212
- return typeof apiKey === "function" ? apiKey : () => apiKey;
213
- }
214
- return void 0;
215
- }
216
- get accessToken() {
217
- const accessToken = this.configuration.accessToken;
218
- if (accessToken) {
219
- return typeof accessToken === "function" ? accessToken : async () => accessToken;
220
- }
221
- return void 0;
222
- }
223
- get headers() {
224
- return this.configuration.headers;
225
- }
226
- get credentials() {
227
- return this.configuration.credentials;
228
- }
229
- };
230
- var DefaultConfig = new Configuration();
231
- var BaseAPI = class _BaseAPI {
232
- constructor(configuration = DefaultConfig) {
233
- this.configuration = configuration;
234
- this.middleware = configuration.middleware;
235
- }
236
- static jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
237
- middleware;
238
- withMiddleware(...middlewares) {
239
- const next = this.clone();
240
- next.middleware = next.middleware.concat(...middlewares);
241
- return next;
242
- }
243
- withPreMiddleware(...preMiddlewares) {
244
- const middlewares = preMiddlewares.map((pre) => ({ pre }));
245
- return this.withMiddleware(...middlewares);
246
- }
247
- withPostMiddleware(...postMiddlewares) {
248
- const middlewares = postMiddlewares.map((post) => ({ post }));
249
- return this.withMiddleware(...middlewares);
250
- }
251
- /**
252
- * Check if the given MIME is a JSON MIME.
253
- * JSON MIME examples:
254
- * application/json
255
- * application/json; charset=UTF8
256
- * APPLICATION/JSON
257
- * application/vnd.company+json
258
- * @param mime - MIME (Multipurpose Internet Mail Extensions)
259
- * @return True if the given MIME is JSON, false otherwise.
260
- */
261
- isJsonMime(mime) {
262
- if (!mime) {
263
- return false;
264
- }
265
- return _BaseAPI.jsonRegex.test(mime);
266
- }
267
- async request(context, initOverrides) {
268
- const { url, init } = await this.createFetchParams(context, initOverrides);
269
- const response = await this.fetchApi(url, init);
270
- if (response && (response.status >= 200 && response.status < 300)) {
271
- return response;
272
- }
273
- throw new ResponseError(response, "Response returned an error code");
274
- }
275
- async createFetchParams(context, initOverrides) {
276
- let url = this.configuration.basePath + context.path;
277
- if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
278
- url += "?" + this.configuration.queryParamsStringify(context.query);
279
- }
280
- const headers = Object.assign({}, this.configuration.headers, context.headers);
281
- Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
282
- const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
283
- const initParams = {
284
- method: context.method,
285
- headers,
286
- body: context.body,
287
- credentials: this.configuration.credentials
288
- };
289
- const overriddenInit = {
290
- ...initParams,
291
- ...await initOverrideFn({
292
- init: initParams,
293
- context
294
- })
295
- };
296
- let body;
297
- if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
298
- body = overriddenInit.body;
299
- } else if (this.isJsonMime(headers["Content-Type"])) {
300
- body = JSON.stringify(overriddenInit.body);
301
- } else {
302
- body = overriddenInit.body;
303
- }
304
- const init = {
305
- ...overriddenInit,
306
- body
307
- };
308
- return { url, init };
309
- }
310
- fetchApi = async (url, init) => {
311
- let fetchParams = { url, init };
312
- for (const middleware of this.middleware) {
313
- if (middleware.pre) {
314
- fetchParams = await middleware.pre({
315
- fetch: this.fetchApi,
316
- ...fetchParams
317
- }) || fetchParams;
318
- }
319
- }
320
- let response = void 0;
321
- try {
322
- response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
323
- } catch (e) {
324
- for (const middleware of this.middleware) {
325
- if (middleware.onError) {
326
- response = await middleware.onError({
327
- fetch: this.fetchApi,
328
- url: fetchParams.url,
329
- init: fetchParams.init,
330
- error: e,
331
- response: response ? response.clone() : void 0
332
- }) || response;
333
- }
334
- }
335
- if (response === void 0) {
336
- if (e instanceof Error) {
337
- throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
338
- } else {
339
- throw e;
340
- }
341
- }
342
- }
343
- for (const middleware of this.middleware) {
344
- if (middleware.post) {
345
- response = await middleware.post({
346
- fetch: this.fetchApi,
347
- url: fetchParams.url,
348
- init: fetchParams.init,
349
- response: response.clone()
350
- }) || response;
351
- }
352
- }
353
- return response;
354
- };
355
- /**
356
- * Create a shallow clone of `this` by constructing a new instance
357
- * and then shallow cloning data members.
358
- */
359
- clone() {
360
- const constructor = this.constructor;
361
- const next = new constructor(this.configuration);
362
- next.middleware = this.middleware.slice();
363
- return next;
364
- }
365
- };
366
- function isBlob(value) {
367
- return typeof Blob !== "undefined" && value instanceof Blob;
368
- }
369
- function isFormData(value) {
370
- return typeof FormData !== "undefined" && value instanceof FormData;
371
- }
372
- var ResponseError = class extends Error {
373
- constructor(response, msg) {
374
- super(msg);
375
- this.response = response;
376
- }
377
- name = "ResponseError";
378
- };
379
- var FetchError = class extends Error {
380
- constructor(cause, msg) {
381
- super(msg);
382
- this.cause = cause;
383
- }
384
- name = "FetchError";
385
- };
386
- var RequiredError = class extends Error {
387
- constructor(field, msg) {
388
- super(msg);
389
- this.field = field;
390
- }
391
- name = "RequiredError";
392
- };
393
- function querystring(params, prefix = "") {
394
- return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
395
- }
396
- function querystringSingleKey(key, value, keyPrefix = "") {
397
- const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
398
- if (value instanceof Array) {
399
- const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
400
- return `${encodeURIComponent(fullKey)}=${multiValue}`;
401
- }
402
- if (value instanceof Set) {
403
- const valueAsArray = Array.from(value);
404
- return querystringSingleKey(key, valueAsArray, keyPrefix);
405
- }
406
- if (value instanceof Date) {
407
- return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
408
- }
409
- if (value instanceof Object) {
410
- return querystring(value, fullKey);
411
- }
412
- return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
413
- }
414
- var JSONApiResponse = class {
415
- constructor(raw, transformer = (jsonValue) => jsonValue) {
416
- this.raw = raw;
417
- this.transformer = transformer;
418
- }
419
- async value() {
420
- return this.transformer(await this.raw.json());
421
- }
422
- };
423
- var VoidApiResponse = class {
424
- constructor(raw) {
425
- this.raw = raw;
426
- }
427
- async value() {
428
- return void 0;
429
- }
430
- };
431
- var TextApiResponse = class {
432
- constructor(raw) {
433
- this.raw = raw;
434
- }
435
- async value() {
436
- return await this.raw.text();
437
- }
438
- };
439
-
440
- // src/generated_api/models/V0PagingResponseModel.ts
441
- function V0PagingResponseModelFromJSON(json) {
442
- return V0PagingResponseModelFromJSONTyped(json, false);
443
- }
444
- function V0PagingResponseModelFromJSONTyped(json, ignoreDiscriminator) {
445
- if (json == null) {
446
- return json;
447
- }
448
- return {
449
- "next": json["next"] == null ? void 0 : json["next"],
450
- "pageItemLimit": json["page_item_limit"] == null ? void 0 : json["page_item_limit"],
451
- "totalItemCount": json["total_item_count"] == null ? void 0 : json["total_item_count"]
452
- };
453
- }
454
-
455
- // src/generated_api/models/V0OwnerAccountResponseModel.ts
456
- function V0OwnerAccountResponseModelFromJSON(json) {
457
- return V0OwnerAccountResponseModelFromJSONTyped(json, false);
458
- }
459
- function V0OwnerAccountResponseModelFromJSONTyped(json, ignoreDiscriminator) {
460
- if (json == null) {
461
- return json;
462
- }
463
- return {
464
- "accountType": json["account_type"] == null ? void 0 : json["account_type"],
465
- "name": json["name"] == null ? void 0 : json["name"],
466
- "slug": json["slug"] == null ? void 0 : json["slug"]
467
- };
468
- }
469
-
470
- // src/generated_api/models/V0AppResponseItemModel.ts
471
- function V0AppResponseItemModelFromJSON(json) {
472
- return V0AppResponseItemModelFromJSONTyped(json, false);
473
- }
474
- function V0AppResponseItemModelFromJSONTyped(json, ignoreDiscriminator) {
475
- if (json == null) {
476
- return json;
477
- }
478
- return {
479
- "avatarUrl": json["avatar_url"] == null ? void 0 : json["avatar_url"],
480
- "isDisabled": json["is_disabled"] == null ? void 0 : json["is_disabled"],
481
- "isGithubChecksEnabled": json["is_github_checks_enabled"] == null ? void 0 : json["is_github_checks_enabled"],
482
- "isPublic": json["is_public"] == null ? void 0 : json["is_public"],
483
- "owner": json["owner"] == null ? void 0 : V0OwnerAccountResponseModelFromJSON(json["owner"]),
484
- "projectId": json["project_id"] == null ? void 0 : json["project_id"],
485
- "projectType": json["project_type"] == null ? void 0 : json["project_type"],
486
- "provider": json["provider"] == null ? void 0 : json["provider"],
487
- "repoOwner": json["repo_owner"] == null ? void 0 : json["repo_owner"],
488
- "repoSlug": json["repo_slug"] == null ? void 0 : json["repo_slug"],
489
- "repoUrl": json["repo_url"] == null ? void 0 : json["repo_url"],
490
- "slug": json["slug"] == null ? void 0 : json["slug"],
491
- "status": json["status"] == null ? void 0 : json["status"],
492
- "title": json["title"] == null ? void 0 : json["title"]
493
- };
494
- }
495
-
496
- // src/generated_api/models/V0ArchivedBuildArtifact.ts
497
- function V0ArchivedBuildArtifactFromJSON(json) {
498
- return V0ArchivedBuildArtifactFromJSONTyped(json, false);
499
- }
500
- function V0ArchivedBuildArtifactFromJSONTyped(json, ignoreDiscriminator) {
501
- if (json == null) {
502
- return json;
503
- }
504
- return {
505
- "artifactMeta": json["artifact_meta"] == null ? void 0 : json["artifact_meta"],
506
- "artifactType": json["artifact_type"] == null ? void 0 : json["artifact_type"],
507
- "createdAt": json["created_at"] == null ? void 0 : json["created_at"],
508
- "fileSizeBytes": json["file_size_bytes"] == null ? void 0 : json["file_size_bytes"],
509
- "id": json["id"] == null ? void 0 : json["id"],
510
- "isPublicPageEnabled": json["is_public_page_enabled"] == null ? void 0 : json["is_public_page_enabled"],
511
- "publicPageToken": json["public_page_token"] == null ? void 0 : json["public_page_token"],
512
- "title": json["title"] == null ? void 0 : json["title"]
513
- };
514
- }
515
-
516
- // src/generated_api/models/V0ArchivedBuildResponseItemModel.ts
517
- function V0ArchivedBuildResponseItemModelFromJSON(json) {
518
- return V0ArchivedBuildResponseItemModelFromJSONTyped(json, false);
519
- }
520
- function V0ArchivedBuildResponseItemModelFromJSONTyped(json, ignoreDiscriminator) {
521
- if (json == null) {
522
- return json;
523
- }
524
- return {
525
- "abortReason": json["abort_reason"] == null ? void 0 : json["abort_reason"],
526
- "branch": json["branch"] == null ? void 0 : json["branch"],
527
- "buildArtifacts": json["build_artifacts"] == null ? void 0 : json["build_artifacts"].map(V0ArchivedBuildArtifactFromJSON),
528
- "buildNumber": json["build_number"] == null ? void 0 : json["build_number"],
529
- "commitHash": json["commit_hash"] == null ? void 0 : json["commit_hash"],
530
- "commitMessage": json["commit_message"] == null ? void 0 : json["commit_message"],
531
- "creditCost": json["credit_cost"] == null ? void 0 : json["credit_cost"],
532
- "finishedAt": json["finished_at"] == null ? void 0 : json["finished_at"],
533
- "machineTypeId": json["machine_type_id"] == null ? void 0 : json["machine_type_id"],
534
- "originalBuildParams": json["original_build_params"] == null ? void 0 : json["original_build_params"],
535
- "pipelineWorkflowId": json["pipeline_workflow_id"] == null ? void 0 : json["pipeline_workflow_id"],
536
- "pullRequestId": json["pull_request_id"] == null ? void 0 : json["pull_request_id"],
537
- "pullRequestTargetBranch": json["pull_request_target_branch"] == null ? void 0 : json["pull_request_target_branch"],
538
- "pullRequestViewUrl": json["pull_request_view_url"] == null ? void 0 : json["pull_request_view_url"],
539
- "slug": json["slug"] == null ? void 0 : json["slug"],
540
- "stackIdentifier": json["stack_identifier"] == null ? void 0 : json["stack_identifier"],
541
- "startedOnWorkerAt": json["started_on_worker_at"] == null ? void 0 : json["started_on_worker_at"],
542
- "status": json["status"] == null ? void 0 : json["status"],
543
- "statusText": json["status_text"] == null ? void 0 : json["status_text"],
544
- "tag": json["tag"] == null ? void 0 : json["tag"],
545
- "triggeredBy": json["triggered_by"] == null ? void 0 : json["triggered_by"],
546
- "triggeredWorkflow": json["triggered_workflow"] == null ? void 0 : json["triggered_workflow"]
547
- };
548
- }
549
-
550
- // src/generated_api/models/V0ArchivedBuildListResponseModel.ts
551
- function V0ArchivedBuildListResponseModelFromJSON(json) {
552
- return V0ArchivedBuildListResponseModelFromJSONTyped(json, false);
553
- }
554
- function V0ArchivedBuildListResponseModelFromJSONTyped(json, ignoreDiscriminator) {
555
- if (json == null) {
556
- return json;
557
- }
558
- return {
559
- "data": json["data"] == null ? void 0 : json["data"].map(V0ArchivedBuildResponseItemModelFromJSON),
560
- "paging": json["paging"] == null ? void 0 : V0PagingResponseModelFromJSON(json["paging"])
561
- };
562
- }
563
-
564
- // src/generated_api/models/V0ArtifactResponseItemModel.ts
565
- function V0ArtifactResponseItemModelFromJSON(json) {
566
- return V0ArtifactResponseItemModelFromJSONTyped(json, false);
567
- }
568
- function V0ArtifactResponseItemModelFromJSONTyped(json, ignoreDiscriminator) {
569
- if (json == null) {
570
- return json;
571
- }
572
- return {
573
- "artifactMeta": json["artifact_meta"] == null ? void 0 : json["artifact_meta"],
574
- "artifactType": json["artifact_type"] == null ? void 0 : json["artifact_type"],
575
- "expiringDownloadUrl": json["expiring_download_url"] == null ? void 0 : json["expiring_download_url"],
576
- "fileSizeBytes": json["file_size_bytes"] == null ? void 0 : json["file_size_bytes"],
577
- "intermediateFileInfo": json["intermediate_file_info"] == null ? void 0 : json["intermediate_file_info"],
578
- "isPublicPageEnabled": json["is_public_page_enabled"] == null ? void 0 : json["is_public_page_enabled"],
579
- "publicInstallPageUrl": json["public_install_page_url"] == null ? void 0 : json["public_install_page_url"],
580
- "slug": json["slug"] == null ? void 0 : json["slug"],
581
- "title": json["title"] == null ? void 0 : json["title"]
582
- };
583
- }
584
-
585
- // src/generated_api/models/V0ArtifactDeleteResponseModel.ts
586
- function V0ArtifactDeleteResponseModelFromJSON(json) {
587
- return V0ArtifactDeleteResponseModelFromJSONTyped(json, false);
588
- }
589
- function V0ArtifactDeleteResponseModelFromJSONTyped(json, ignoreDiscriminator) {
590
- if (json == null) {
591
- return json;
592
- }
593
- return {
594
- "data": json["data"] == null ? void 0 : V0ArtifactResponseItemModelFromJSON(json["data"])
595
- };
596
- }
597
-
598
- // src/generated_api/models/V0ArtifactListElementResponseModel.ts
599
- function V0ArtifactListElementResponseModelFromJSON(json) {
600
- return V0ArtifactListElementResponseModelFromJSONTyped(json, false);
601
- }
602
- function V0ArtifactListElementResponseModelFromJSONTyped(json, ignoreDiscriminator) {
603
- if (json == null) {
604
- return json;
605
- }
606
- return {
607
- "artifactMeta": json["artifact_meta"] == null ? void 0 : json["artifact_meta"],
608
- "artifactType": json["artifact_type"] == null ? void 0 : json["artifact_type"],
609
- "fileSizeBytes": json["file_size_bytes"] == null ? void 0 : json["file_size_bytes"],
610
- "intermediateFileInfo": json["intermediate_file_info"] == null ? void 0 : json["intermediate_file_info"],
611
- "isPublicPageEnabled": json["is_public_page_enabled"] == null ? void 0 : json["is_public_page_enabled"],
612
- "slug": json["slug"] == null ? void 0 : json["slug"],
613
- "title": json["title"] == null ? void 0 : json["title"]
614
- };
615
- }
616
-
617
- // src/generated_api/models/V0ArtifactListResponseModel.ts
618
- function V0ArtifactListResponseModelFromJSON(json) {
619
- return V0ArtifactListResponseModelFromJSONTyped(json, false);
620
- }
621
- function V0ArtifactListResponseModelFromJSONTyped(json, ignoreDiscriminator) {
622
- if (json == null) {
623
- return json;
624
- }
625
- return {
626
- "data": json["data"] == null ? void 0 : json["data"].map(V0ArtifactListElementResponseModelFromJSON),
627
- "paging": json["paging"] == null ? void 0 : V0PagingResponseModelFromJSON(json["paging"])
628
- };
629
- }
630
-
631
- // src/generated_api/models/V0ArtifactShowResponseModel.ts
632
- function V0ArtifactShowResponseModelFromJSON(json) {
633
- return V0ArtifactShowResponseModelFromJSONTyped(json, false);
634
- }
635
- function V0ArtifactShowResponseModelFromJSONTyped(json, ignoreDiscriminator) {
636
- if (json == null) {
637
- return json;
638
- }
639
- return {
640
- "data": json["data"] == null ? void 0 : V0ArtifactResponseItemModelFromJSON(json["data"])
641
- };
642
- }
643
-
644
- // src/generated_api/models/V0ArtifactUpdateParams.ts
645
- function V0ArtifactUpdateParamsToJSON(json) {
646
- return V0ArtifactUpdateParamsToJSONTyped(json, false);
647
- }
648
- function V0ArtifactUpdateParamsToJSONTyped(value, ignoreDiscriminator = false) {
649
- if (value == null) {
650
- return value;
651
- }
652
- return {
653
- "is_public_page_enabled": value["isPublicPageEnabled"]
654
- };
655
- }
656
-
657
- // src/generated_api/models/V0BuildAbortParams.ts
658
- function V0BuildAbortParamsToJSON(json) {
659
- return V0BuildAbortParamsToJSONTyped(json, false);
660
- }
661
- function V0BuildAbortParamsToJSONTyped(value, ignoreDiscriminator = false) {
662
- if (value == null) {
663
- return value;
664
- }
665
- return {
666
- "abort_reason": value["abortReason"],
667
- "abort_with_success": value["abortWithSuccess"],
668
- "skip_notifications": value["skipNotifications"]
669
- };
670
- }
671
-
672
- // src/generated_api/models/V0BuildAbortResponseModel.ts
673
- function V0BuildAbortResponseModelFromJSON(json) {
674
- return V0BuildAbortResponseModelFromJSONTyped(json, false);
675
- }
676
- function V0BuildAbortResponseModelFromJSONTyped(json, ignoreDiscriminator) {
677
- if (json == null) {
678
- return json;
679
- }
680
- return {
681
- "status": json["status"] == null ? void 0 : json["status"]
682
- };
683
- }
684
-
685
- // src/generated_api/models/V0BuildListAllResponseItemModel.ts
686
- function V0BuildListAllResponseItemModelFromJSON(json) {
687
- return V0BuildListAllResponseItemModelFromJSONTyped(json, false);
688
- }
689
- function V0BuildListAllResponseItemModelFromJSONTyped(json, ignoreDiscriminator) {
690
- if (json == null) {
691
- return json;
692
- }
693
- return {
694
- "abortReason": json["abort_reason"] == null ? void 0 : json["abort_reason"],
695
- "branch": json["branch"] == null ? void 0 : json["branch"],
696
- "buildNumber": json["build_number"] == null ? void 0 : json["build_number"],
697
- "commitHash": json["commit_hash"] == null ? void 0 : json["commit_hash"],
698
- "commitMessage": json["commit_message"] == null ? void 0 : json["commit_message"],
699
- "commitViewUrl": json["commit_view_url"] == null ? void 0 : json["commit_view_url"],
700
- "creditCost": json["credit_cost"] == null ? void 0 : json["credit_cost"],
701
- "environmentPrepareFinishedAt": json["environment_prepare_finished_at"] == null ? void 0 : json["environment_prepare_finished_at"],
702
- "finishedAt": json["finished_at"] == null ? void 0 : json["finished_at"],
703
- "isOnHold": json["is_on_hold"] == null ? void 0 : json["is_on_hold"],
704
- "isProcessed": json["is_processed"] == null ? void 0 : json["is_processed"],
705
- "machineTypeId": json["machine_type_id"] == null ? void 0 : json["machine_type_id"],
706
- "originalBuildParams": json["original_build_params"] == null ? void 0 : json["original_build_params"],
707
- "pullRequestId": json["pull_request_id"] == null ? void 0 : json["pull_request_id"],
708
- "pullRequestTargetBranch": json["pull_request_target_branch"] == null ? void 0 : json["pull_request_target_branch"],
709
- "pullRequestViewUrl": json["pull_request_view_url"] == null ? void 0 : json["pull_request_view_url"],
710
- "repository": json["repository"] == null ? void 0 : V0AppResponseItemModelFromJSON(json["repository"]),
711
- "slug": json["slug"] == null ? void 0 : json["slug"],
712
- "stackIdentifier": json["stack_identifier"] == null ? void 0 : json["stack_identifier"],
713
- "startedOnWorkerAt": json["started_on_worker_at"] == null ? void 0 : json["started_on_worker_at"],
714
- "status": json["status"] == null ? void 0 : json["status"],
715
- "statusText": json["status_text"] == null ? void 0 : json["status_text"],
716
- "tag": json["tag"] == null ? void 0 : json["tag"],
717
- "triggeredAt": json["triggered_at"] == null ? void 0 : json["triggered_at"],
718
- "triggeredBy": json["triggered_by"] == null ? void 0 : json["triggered_by"],
719
- "triggeredWorkflow": json["triggered_workflow"] == null ? void 0 : json["triggered_workflow"]
720
- };
721
- }
722
-
723
- // src/generated_api/models/V0BuildListAllResponseModel.ts
724
- function V0BuildListAllResponseModelFromJSON(json) {
725
- return V0BuildListAllResponseModelFromJSONTyped(json, false);
726
- }
727
- function V0BuildListAllResponseModelFromJSONTyped(json, ignoreDiscriminator) {
728
- if (json == null) {
729
- return json;
730
- }
731
- return {
732
- "data": json["data"] == null ? void 0 : json["data"].map(V0BuildListAllResponseItemModelFromJSON),
733
- "paging": json["paging"] == null ? void 0 : V0PagingResponseModelFromJSON(json["paging"])
734
- };
735
- }
736
-
737
- // src/generated_api/models/V0BuildResponseItemModel.ts
738
- function V0BuildResponseItemModelFromJSON(json) {
739
- return V0BuildResponseItemModelFromJSONTyped(json, false);
740
- }
741
- function V0BuildResponseItemModelFromJSONTyped(json, ignoreDiscriminator) {
742
- if (json == null) {
743
- return json;
744
- }
745
- return {
746
- "abortReason": json["abort_reason"] == null ? void 0 : json["abort_reason"],
747
- "branch": json["branch"] == null ? void 0 : json["branch"],
748
- "buildNumber": json["build_number"] == null ? void 0 : json["build_number"],
749
- "commitHash": json["commit_hash"] == null ? void 0 : json["commit_hash"],
750
- "commitMessage": json["commit_message"] == null ? void 0 : json["commit_message"],
751
- "commitViewUrl": json["commit_view_url"] == null ? void 0 : json["commit_view_url"],
752
- "creditCost": json["credit_cost"] == null ? void 0 : json["credit_cost"],
753
- "environmentPrepareFinishedAt": json["environment_prepare_finished_at"] == null ? void 0 : json["environment_prepare_finished_at"],
754
- "finishedAt": json["finished_at"] == null ? void 0 : json["finished_at"],
755
- "isOnHold": json["is_on_hold"] == null ? void 0 : json["is_on_hold"],
756
- "isProcessed": json["is_processed"] == null ? void 0 : json["is_processed"],
757
- "isStatusSent": json["is_status_sent"] == null ? void 0 : json["is_status_sent"],
758
- "logFormat": json["log_format"] == null ? void 0 : json["log_format"],
759
- "machineTypeId": json["machine_type_id"] == null ? void 0 : json["machine_type_id"],
760
- "originalBuildParams": json["original_build_params"] == null ? void 0 : json["original_build_params"],
761
- "pipelineWorkflowId": json["pipeline_workflow_id"] == null ? void 0 : json["pipeline_workflow_id"],
762
- "pullRequestId": json["pull_request_id"] == null ? void 0 : json["pull_request_id"],
763
- "pullRequestTargetBranch": json["pull_request_target_branch"] == null ? void 0 : json["pull_request_target_branch"],
764
- "pullRequestViewUrl": json["pull_request_view_url"] == null ? void 0 : json["pull_request_view_url"],
765
- "rebuildable": json["rebuildable"] == null ? void 0 : json["rebuildable"],
766
- "slug": json["slug"] == null ? void 0 : json["slug"],
767
- "stackIdentifier": json["stack_identifier"] == null ? void 0 : json["stack_identifier"],
768
- "startedOnWorkerAt": json["started_on_worker_at"] == null ? void 0 : json["started_on_worker_at"],
769
- "status": json["status"] == null ? void 0 : json["status"],
770
- "statusText": json["status_text"] == null ? void 0 : json["status_text"],
771
- "tag": json["tag"] == null ? void 0 : json["tag"],
772
- "triggeredAt": json["triggered_at"] == null ? void 0 : json["triggered_at"],
773
- "triggeredBy": json["triggered_by"] == null ? void 0 : json["triggered_by"],
774
- "triggeredWorkflow": json["triggered_workflow"] == null ? void 0 : json["triggered_workflow"]
775
- };
776
- }
777
-
778
- // src/generated_api/models/V0BuildListResponseModel.ts
779
- function V0BuildListResponseModelFromJSON(json) {
780
- return V0BuildListResponseModelFromJSONTyped(json, false);
781
- }
782
- function V0BuildListResponseModelFromJSONTyped(json, ignoreDiscriminator) {
783
- if (json == null) {
784
- return json;
785
- }
786
- return {
787
- "data": json["data"] == null ? void 0 : json["data"].map(V0BuildResponseItemModelFromJSON),
788
- "paging": json["paging"] == null ? void 0 : V0PagingResponseModelFromJSON(json["paging"])
789
- };
790
- }
791
-
792
- // src/generated_api/models/V0BuildParamsEnvironment.ts
793
- function V0BuildParamsEnvironmentToJSON(json) {
794
- return V0BuildParamsEnvironmentToJSONTyped(json, false);
795
- }
796
- function V0BuildParamsEnvironmentToJSONTyped(value, ignoreDiscriminator = false) {
797
- if (value == null) {
798
- return value;
799
- }
800
- return {
801
- "is_expand": value["isExpand"],
802
- "mapped_to": value["mappedTo"],
803
- "value": value["value"]
804
- };
805
- }
806
-
807
- // src/generated_api/models/V0BuildShowResponseModel.ts
808
- function V0BuildShowResponseModelFromJSON(json) {
809
- return V0BuildShowResponseModelFromJSONTyped(json, false);
810
- }
811
- function V0BuildShowResponseModelFromJSONTyped(json, ignoreDiscriminator) {
812
- if (json == null) {
813
- return json;
814
- }
815
- return {
816
- "data": json["data"] == null ? void 0 : V0BuildResponseItemModelFromJSON(json["data"])
817
- };
818
- }
819
-
820
- // src/generated_api/models/V0CommitPaths.ts
821
- function V0CommitPathsToJSON(json) {
822
- return V0CommitPathsToJSONTyped(json, false);
823
- }
824
- function V0CommitPathsToJSONTyped(value, ignoreDiscriminator = false) {
825
- if (value == null) {
826
- return value;
827
- }
828
- return {
829
- "added": value["added"],
830
- "modified": value["modified"],
831
- "removed": value["removed"]
832
- };
833
- }
834
-
835
- // src/generated_api/models/V0BuildTriggerParamsBuildParams.ts
836
- function V0BuildTriggerParamsBuildParamsToJSON(json) {
837
- return V0BuildTriggerParamsBuildParamsToJSONTyped(json, false);
838
- }
839
- function V0BuildTriggerParamsBuildParamsToJSONTyped(value, ignoreDiscriminator = false) {
840
- if (value == null) {
841
- return value;
842
- }
843
- return {
844
- "base_repository_url": value["baseRepositoryUrl"],
845
- "branch": value["branch"],
846
- "branch_dest": value["branchDest"],
847
- "branch_dest_repo_owner": value["branchDestRepoOwner"],
848
- "branch_repo_owner": value["branchRepoOwner"],
849
- "build_request_slug": value["buildRequestSlug"],
850
- "commit_hash": value["commitHash"],
851
- "commit_message": value["commitMessage"],
852
- "commit_paths": value["commitPaths"] == null ? void 0 : value["commitPaths"].map(V0CommitPathsToJSON),
853
- "diff_url": value["diffUrl"],
854
- "environments": value["environments"] == null ? void 0 : value["environments"].map(V0BuildParamsEnvironmentToJSON),
855
- "head_repository_url": value["headRepositoryUrl"],
856
- "pipeline_id": value["pipelineId"],
857
- "priority": value["priority"],
858
- "pull_request_author": value["pullRequestAuthor"],
859
- "pull_request_head_branch": value["pullRequestHeadBranch"],
860
- "pull_request_id": value["pullRequestId"],
861
- "pull_request_merge_branch": value["pullRequestMergeBranch"],
862
- "pull_request_repository_url": value["pullRequestRepositoryUrl"],
863
- "pull_request_unverified_merge_branch": value["pullRequestUnverifiedMergeBranch"],
864
- "skip_git_status_report": value["skipGitStatusReport"],
865
- "tag": value["tag"],
866
- "workflow_id": value["workflowId"]
867
- };
868
- }
869
-
870
- // src/generated_api/models/V0BuildTriggerParamsHookInfo.ts
871
- function V0BuildTriggerParamsHookInfoToJSON(json) {
872
- return V0BuildTriggerParamsHookInfoToJSONTyped(json, false);
873
- }
874
- function V0BuildTriggerParamsHookInfoToJSONTyped(value, ignoreDiscriminator = false) {
875
- if (value == null) {
876
- return value;
877
- }
878
- return {
879
- "type": value["type"]
880
- };
881
- }
882
-
883
- // src/generated_api/models/V0BuildTriggerParams.ts
884
- function V0BuildTriggerParamsToJSON(json) {
885
- return V0BuildTriggerParamsToJSONTyped(json, false);
886
- }
887
- function V0BuildTriggerParamsToJSONTyped(value, ignoreDiscriminator = false) {
888
- if (value == null) {
889
- return value;
890
- }
891
- return {
892
- "build_params": V0BuildTriggerParamsBuildParamsToJSON(value["buildParams"]),
893
- "hook_info": V0BuildTriggerParamsHookInfoToJSON(value["hookInfo"])
894
- };
895
- }
896
-
897
- // src/generated_api/models/V0BuildTriggerRespItemModel.ts
898
- function V0BuildTriggerRespItemModelFromJSON(json) {
899
- return V0BuildTriggerRespItemModelFromJSONTyped(json, false);
900
- }
901
- function V0BuildTriggerRespItemModelFromJSONTyped(json, ignoreDiscriminator) {
902
- if (json == null) {
903
- return json;
904
- }
905
- return {
906
- "buildNumber": json["build_number"] == null ? void 0 : json["build_number"],
907
- "buildSlug": json["build_slug"] == null ? void 0 : json["build_slug"],
908
- "buildUrl": json["build_url"] == null ? void 0 : json["build_url"],
909
- "message": json["message"] == null ? void 0 : json["message"],
910
- "status": json["status"] == null ? void 0 : json["status"],
911
- "triggeredPipeline": json["triggered_pipeline"] == null ? void 0 : json["triggered_pipeline"],
912
- "triggeredWorkflow": json["triggered_workflow"] == null ? void 0 : json["triggered_workflow"]
913
- };
914
- }
915
-
916
- // src/generated_api/models/V0BuildTriggerRespModel.ts
917
- function V0BuildTriggerRespModelFromJSON(json) {
918
- return V0BuildTriggerRespModelFromJSONTyped(json, false);
919
- }
920
- function V0BuildTriggerRespModelFromJSONTyped(json, ignoreDiscriminator) {
921
- if (json == null) {
922
- return json;
923
- }
924
- return {
925
- "buildNumber": json["build_number"] == null ? void 0 : json["build_number"],
926
- "buildSlug": json["build_slug"] == null ? void 0 : json["build_slug"],
927
- "buildUrl": json["build_url"] == null ? void 0 : json["build_url"],
928
- "message": json["message"] == null ? void 0 : json["message"],
929
- "results": json["results"] == null ? void 0 : json["results"].map(V0BuildTriggerRespItemModelFromJSON),
930
- "service": json["service"] == null ? void 0 : json["service"],
931
- "slug": json["slug"] == null ? void 0 : json["slug"],
932
- "status": json["status"] == null ? void 0 : json["status"],
933
- "triggeredWorkflow": json["triggered_workflow"] == null ? void 0 : json["triggered_workflow"]
934
- };
935
- }
936
-
937
- // src/generated_api/models/V0BuildWorkflowListResponseModel.ts
938
- function V0BuildWorkflowListResponseModelFromJSON(json) {
939
- return V0BuildWorkflowListResponseModelFromJSONTyped(json, false);
940
- }
941
- function V0BuildWorkflowListResponseModelFromJSONTyped(json, ignoreDiscriminator) {
942
- if (json == null) {
943
- return json;
944
- }
945
- return {
946
- "data": json["data"] == null ? void 0 : json["data"]
947
- };
948
- }
949
-
950
- // src/generated_api/apis/BuildArtifactApi.ts
951
- var BuildArtifactApi = class extends BaseAPI {
952
- /**
953
- * Delete a build artifact of an app\'s build. The required parameters are app slug, build slug and artifact slug. You can fetch the build artifact slug if you first list all build artifacts of an app with the [/apps/](https://api-docs.bitrise.io/#/build-artifact/artifact-list) endpoint.
954
- * Delete a build artifact
955
- */
956
- async artifactDeleteRaw(requestParameters, initOverrides) {
957
- if (requestParameters["appSlug"] == null) {
958
- throw new RequiredError(
959
- "appSlug",
960
- 'Required parameter "appSlug" was null or undefined when calling artifactDelete().'
961
- );
962
- }
963
- if (requestParameters["buildSlug"] == null) {
964
- throw new RequiredError(
965
- "buildSlug",
966
- 'Required parameter "buildSlug" was null or undefined when calling artifactDelete().'
967
- );
968
- }
969
- if (requestParameters["artifactSlug"] == null) {
970
- throw new RequiredError(
971
- "artifactSlug",
972
- 'Required parameter "artifactSlug" was null or undefined when calling artifactDelete().'
973
- );
974
- }
975
- const queryParameters = {};
976
- const headerParameters = {};
977
- if (this.configuration && this.configuration.apiKey) {
978
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
979
- }
980
- const response = await this.request({
981
- path: `/apps/{app-slug}/builds/{build-slug}/artifacts/{artifact-slug}`.replace(`{${"app-slug"}}`, encodeURIComponent(String(requestParameters["appSlug"]))).replace(`{${"build-slug"}}`, encodeURIComponent(String(requestParameters["buildSlug"]))).replace(`{${"artifact-slug"}}`, encodeURIComponent(String(requestParameters["artifactSlug"]))),
982
- method: "DELETE",
983
- headers: headerParameters,
984
- query: queryParameters
985
- }, initOverrides);
986
- return new JSONApiResponse(response, (jsonValue) => V0ArtifactDeleteResponseModelFromJSON(jsonValue));
987
- }
988
- /**
989
- * Delete a build artifact of an app\'s build. The required parameters are app slug, build slug and artifact slug. You can fetch the build artifact slug if you first list all build artifacts of an app with the [/apps/](https://api-docs.bitrise.io/#/build-artifact/artifact-list) endpoint.
990
- * Delete a build artifact
991
- */
992
- async artifactDelete(requestParameters, initOverrides) {
993
- const response = await this.artifactDeleteRaw(requestParameters, initOverrides);
994
- return await response.value();
995
- }
996
- /**
997
- * List all build artifacts that have been generated for an app\'s build. This endpoint can retrieve artifacts from the archive as well. You can use the created build artifact slugs from the response output to retrieve data of a specific build artifact with the [GET/apps/](https://api-docs.bitrise.io/#/build-artifact/artifact-show) endpoint or update a build artifact with the [PATCH/apps](https://api-docs.bitrise.io/#/build-artifact/artifact-update) endpoint.
998
- * Get a list of all build artifacts
999
- */
1000
- async artifactListRaw(requestParameters, initOverrides) {
1001
- if (requestParameters["appSlug"] == null) {
1002
- throw new RequiredError(
1003
- "appSlug",
1004
- 'Required parameter "appSlug" was null or undefined when calling artifactList().'
1005
- );
1006
- }
1007
- if (requestParameters["buildSlug"] == null) {
1008
- throw new RequiredError(
1009
- "buildSlug",
1010
- 'Required parameter "buildSlug" was null or undefined when calling artifactList().'
1011
- );
1012
- }
1013
- const queryParameters = {};
1014
- if (requestParameters["next"] != null) {
1015
- queryParameters["next"] = requestParameters["next"];
1016
- }
1017
- if (requestParameters["limit"] != null) {
1018
- queryParameters["limit"] = requestParameters["limit"];
1019
- }
1020
- const headerParameters = {};
1021
- if (this.configuration && this.configuration.apiKey) {
1022
- headerParameters["Bitrise-Addon-Auth-Token"] = await this.configuration.apiKey("Bitrise-Addon-Auth-Token");
1023
- }
1024
- if (this.configuration && this.configuration.apiKey) {
1025
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
1026
- }
1027
- const response = await this.request({
1028
- path: `/apps/{app-slug}/builds/{build-slug}/artifacts`.replace(`{${"app-slug"}}`, encodeURIComponent(String(requestParameters["appSlug"]))).replace(`{${"build-slug"}}`, encodeURIComponent(String(requestParameters["buildSlug"]))),
1029
- method: "GET",
1030
- headers: headerParameters,
1031
- query: queryParameters
1032
- }, initOverrides);
1033
- return new JSONApiResponse(response, (jsonValue) => V0ArtifactListResponseModelFromJSON(jsonValue));
1034
- }
1035
- /**
1036
- * List all build artifacts that have been generated for an app\'s build. This endpoint can retrieve artifacts from the archive as well. You can use the created build artifact slugs from the response output to retrieve data of a specific build artifact with the [GET/apps/](https://api-docs.bitrise.io/#/build-artifact/artifact-show) endpoint or update a build artifact with the [PATCH/apps](https://api-docs.bitrise.io/#/build-artifact/artifact-update) endpoint.
1037
- * Get a list of all build artifacts
1038
- */
1039
- async artifactList(requestParameters, initOverrides) {
1040
- const response = await this.artifactListRaw(requestParameters, initOverrides);
1041
- return await response.value();
1042
- }
1043
- /**
1044
- * Retrieve data of a specific build artifact. The endpoint can retrieve archived artifacts as well. The response output contains a time-limited download url (expires in 10 minutes) and a public install-page URL. You can view the build artifact with both URLs, but the public install-page url will not work unless you [enable it](https://devcenter.bitrise.io/tutorials/deploy/bitrise-app-deployment/#enabling-public-page-for-the-app).
1045
- * Get a specific build artifact
1046
- */
1047
- async artifactShowRaw(requestParameters, initOverrides) {
1048
- if (requestParameters["appSlug"] == null) {
1049
- throw new RequiredError(
1050
- "appSlug",
1051
- 'Required parameter "appSlug" was null or undefined when calling artifactShow().'
1052
- );
1053
- }
1054
- if (requestParameters["buildSlug"] == null) {
1055
- throw new RequiredError(
1056
- "buildSlug",
1057
- 'Required parameter "buildSlug" was null or undefined when calling artifactShow().'
1058
- );
1059
- }
1060
- if (requestParameters["artifactSlug"] == null) {
1061
- throw new RequiredError(
1062
- "artifactSlug",
1063
- 'Required parameter "artifactSlug" was null or undefined when calling artifactShow().'
1064
- );
1065
- }
1066
- const queryParameters = {};
1067
- if (requestParameters["download"] != null) {
1068
- queryParameters["download"] = requestParameters["download"];
1069
- }
1070
- const headerParameters = {};
1071
- if (this.configuration && this.configuration.apiKey) {
1072
- headerParameters["Bitrise-Addon-Auth-Token"] = await this.configuration.apiKey("Bitrise-Addon-Auth-Token");
1073
- }
1074
- if (this.configuration && this.configuration.apiKey) {
1075
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
1076
- }
1077
- const response = await this.request({
1078
- path: `/apps/{app-slug}/builds/{build-slug}/artifacts/{artifact-slug}`.replace(`{${"app-slug"}}`, encodeURIComponent(String(requestParameters["appSlug"]))).replace(`{${"build-slug"}}`, encodeURIComponent(String(requestParameters["buildSlug"]))).replace(`{${"artifact-slug"}}`, encodeURIComponent(String(requestParameters["artifactSlug"]))),
1079
- method: "GET",
1080
- headers: headerParameters,
1081
- query: queryParameters
1082
- }, initOverrides);
1083
- return new JSONApiResponse(response, (jsonValue) => V0ArtifactShowResponseModelFromJSON(jsonValue));
1084
- }
1085
- /**
1086
- * Retrieve data of a specific build artifact. The endpoint can retrieve archived artifacts as well. The response output contains a time-limited download url (expires in 10 minutes) and a public install-page URL. You can view the build artifact with both URLs, but the public install-page url will not work unless you [enable it](https://devcenter.bitrise.io/tutorials/deploy/bitrise-app-deployment/#enabling-public-page-for-the-app).
1087
- * Get a specific build artifact
1088
- */
1089
- async artifactShow(requestParameters, initOverrides) {
1090
- const response = await this.artifactShowRaw(requestParameters, initOverrides);
1091
- return await response.value();
1092
- }
1093
- /**
1094
- * Update the `is_public_page_enabled` attribute of your app\'s build. The required parameters are app slug, build slug and artifact slug. You can fetch the build artifact slug if you first list all build artifacts of an app with the [GET /apps/](https://api-docs.bitrise.io/#/build-artifact/artifact-list) endpoint.
1095
- * Update a build artifact
1096
- */
1097
- async artifactUpdateRaw(requestParameters, initOverrides) {
1098
- if (requestParameters["appSlug"] == null) {
1099
- throw new RequiredError(
1100
- "appSlug",
1101
- 'Required parameter "appSlug" was null or undefined when calling artifactUpdate().'
1102
- );
1103
- }
1104
- if (requestParameters["buildSlug"] == null) {
1105
- throw new RequiredError(
1106
- "buildSlug",
1107
- 'Required parameter "buildSlug" was null or undefined when calling artifactUpdate().'
1108
- );
1109
- }
1110
- if (requestParameters["artifactSlug"] == null) {
1111
- throw new RequiredError(
1112
- "artifactSlug",
1113
- 'Required parameter "artifactSlug" was null or undefined when calling artifactUpdate().'
1114
- );
1115
- }
1116
- if (requestParameters["artifactParams"] == null) {
1117
- throw new RequiredError(
1118
- "artifactParams",
1119
- 'Required parameter "artifactParams" was null or undefined when calling artifactUpdate().'
1120
- );
1121
- }
1122
- const queryParameters = {};
1123
- const headerParameters = {};
1124
- headerParameters["Content-Type"] = "application/json";
1125
- if (this.configuration && this.configuration.apiKey) {
1126
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
1127
- }
1128
- const response = await this.request({
1129
- path: `/apps/{app-slug}/builds/{build-slug}/artifacts/{artifact-slug}`.replace(`{${"app-slug"}}`, encodeURIComponent(String(requestParameters["appSlug"]))).replace(`{${"build-slug"}}`, encodeURIComponent(String(requestParameters["buildSlug"]))).replace(`{${"artifact-slug"}}`, encodeURIComponent(String(requestParameters["artifactSlug"]))),
1130
- method: "PATCH",
1131
- headers: headerParameters,
1132
- query: queryParameters,
1133
- body: V0ArtifactUpdateParamsToJSON(requestParameters["artifactParams"])
1134
- }, initOverrides);
1135
- return new JSONApiResponse(response, (jsonValue) => V0ArtifactShowResponseModelFromJSON(jsonValue));
1136
- }
1137
- /**
1138
- * Update the `is_public_page_enabled` attribute of your app\'s build. The required parameters are app slug, build slug and artifact slug. You can fetch the build artifact slug if you first list all build artifacts of an app with the [GET /apps/](https://api-docs.bitrise.io/#/build-artifact/artifact-list) endpoint.
1139
- * Update a build artifact
1140
- */
1141
- async artifactUpdate(requestParameters, initOverrides) {
1142
- const response = await this.artifactUpdateRaw(requestParameters, initOverrides);
1143
- return await response.value();
1144
- }
1145
- };
1146
-
1147
- // src/generated_api/apis/BuildsApi.ts
1148
- var BuildsApi = class extends BaseAPI {
1149
- /**
1150
- * List the first 1000 archived builds of a specified Bitrise app. Set parameters to filter builds:
1151
- * List 1000 archived builds of an app
1152
- */
1153
- async archivedBuildsListRaw(requestParameters, initOverrides) {
1154
- if (requestParameters["appSlug"] == null) {
1155
- throw new RequiredError(
1156
- "appSlug",
1157
- 'Required parameter "appSlug" was null or undefined when calling archivedBuildsList().'
1158
- );
1159
- }
1160
- if (requestParameters["after"] == null) {
1161
- throw new RequiredError(
1162
- "after",
1163
- 'Required parameter "after" was null or undefined when calling archivedBuildsList().'
1164
- );
1165
- }
1166
- if (requestParameters["before"] == null) {
1167
- throw new RequiredError(
1168
- "before",
1169
- 'Required parameter "before" was null or undefined when calling archivedBuildsList().'
1170
- );
1171
- }
1172
- if (requestParameters["limit"] == null) {
1173
- throw new RequiredError(
1174
- "limit",
1175
- 'Required parameter "limit" was null or undefined when calling archivedBuildsList().'
1176
- );
1177
- }
1178
- const queryParameters = {};
1179
- if (requestParameters["after"] != null) {
1180
- queryParameters["after"] = requestParameters["after"];
1181
- }
1182
- if (requestParameters["before"] != null) {
1183
- queryParameters["before"] = requestParameters["before"];
1184
- }
1185
- if (requestParameters["limit"] != null) {
1186
- queryParameters["limit"] = requestParameters["limit"];
1187
- }
1188
- const headerParameters = {};
1189
- if (this.configuration && this.configuration.apiKey) {
1190
- headerParameters["Bitrise-Addon-Auth-Token"] = await this.configuration.apiKey("Bitrise-Addon-Auth-Token");
1191
- }
1192
- if (this.configuration && this.configuration.apiKey) {
1193
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
1194
- }
1195
- const response = await this.request({
1196
- path: `/apps/{app-slug}/archived-builds`.replace(`{${"app-slug"}}`, encodeURIComponent(String(requestParameters["appSlug"]))),
1197
- method: "GET",
1198
- headers: headerParameters,
1199
- query: queryParameters
1200
- }, initOverrides);
1201
- return new JSONApiResponse(response, (jsonValue) => V0ArchivedBuildListResponseModelFromJSON(jsonValue));
1202
- }
1203
- /**
1204
- * List the first 1000 archived builds of a specified Bitrise app. Set parameters to filter builds:
1205
- * List 1000 archived builds of an app
1206
- */
1207
- async archivedBuildsList(requestParameters, initOverrides) {
1208
- const response = await this.archivedBuildsListRaw(requestParameters, initOverrides);
1209
- return await response.value();
1210
- }
1211
- /**
1212
- * Abort a specific build. Set an abort reason with the `abort_reason` parameter. Use the `abort_with_success` parameter to abort a build but still count it as a successful one.
1213
- * Abort a specific build
1214
- */
1215
- async buildAbortRaw(requestParameters, initOverrides) {
1216
- if (requestParameters["appSlug"] == null) {
1217
- throw new RequiredError(
1218
- "appSlug",
1219
- 'Required parameter "appSlug" was null or undefined when calling buildAbort().'
1220
- );
1221
- }
1222
- if (requestParameters["buildSlug"] == null) {
1223
- throw new RequiredError(
1224
- "buildSlug",
1225
- 'Required parameter "buildSlug" was null or undefined when calling buildAbort().'
1226
- );
1227
- }
1228
- if (requestParameters["buildAbortParams"] == null) {
1229
- throw new RequiredError(
1230
- "buildAbortParams",
1231
- 'Required parameter "buildAbortParams" was null or undefined when calling buildAbort().'
1232
- );
1233
- }
1234
- const queryParameters = {};
1235
- const headerParameters = {};
1236
- headerParameters["Content-Type"] = "application/json";
1237
- if (this.configuration && this.configuration.apiKey) {
1238
- headerParameters["Bitrise-Addon-Auth-Token"] = await this.configuration.apiKey("Bitrise-Addon-Auth-Token");
1239
- }
1240
- if (this.configuration && this.configuration.apiKey) {
1241
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
1242
- }
1243
- const response = await this.request({
1244
- path: `/apps/{app-slug}/builds/{build-slug}/abort`.replace(`{${"app-slug"}}`, encodeURIComponent(String(requestParameters["appSlug"]))).replace(`{${"build-slug"}}`, encodeURIComponent(String(requestParameters["buildSlug"]))),
1245
- method: "POST",
1246
- headers: headerParameters,
1247
- query: queryParameters,
1248
- body: V0BuildAbortParamsToJSON(requestParameters["buildAbortParams"])
1249
- }, initOverrides);
1250
- return new JSONApiResponse(response, (jsonValue) => V0BuildAbortResponseModelFromJSON(jsonValue));
1251
- }
1252
- /**
1253
- * Abort a specific build. Set an abort reason with the `abort_reason` parameter. Use the `abort_with_success` parameter to abort a build but still count it as a successful one.
1254
- * Abort a specific build
1255
- */
1256
- async buildAbort(requestParameters, initOverrides) {
1257
- const response = await this.buildAbortRaw(requestParameters, initOverrides);
1258
- return await response.value();
1259
- }
1260
- /**
1261
- * Get the bitrise.yml file of one of the builds of a given app. This will return the `bitrise.yml` configuration with which the build ran. You can compare it to [the current bitrise.yml configuration](https://api-docs.bitrise.io/#/application/app-config-datastore-show) of the app.
1262
- * Get the bitrise.yml of a build
1263
- */
1264
- async buildBitriseYmlShowRaw(requestParameters, initOverrides) {
1265
- if (requestParameters["appSlug"] == null) {
1266
- throw new RequiredError(
1267
- "appSlug",
1268
- 'Required parameter "appSlug" was null or undefined when calling buildBitriseYmlShow().'
1269
- );
1270
- }
1271
- if (requestParameters["buildSlug"] == null) {
1272
- throw new RequiredError(
1273
- "buildSlug",
1274
- 'Required parameter "buildSlug" was null or undefined when calling buildBitriseYmlShow().'
1275
- );
1276
- }
1277
- const queryParameters = {};
1278
- const headerParameters = {};
1279
- if (this.configuration && this.configuration.apiKey) {
1280
- headerParameters["Bitrise-Addon-Auth-Token"] = await this.configuration.apiKey("Bitrise-Addon-Auth-Token");
1281
- }
1282
- if (this.configuration && this.configuration.apiKey) {
1283
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
1284
- }
1285
- const response = await this.request({
1286
- path: `/apps/{app-slug}/builds/{build-slug}/bitrise.yml`.replace(`{${"app-slug"}}`, encodeURIComponent(String(requestParameters["appSlug"]))).replace(`{${"build-slug"}}`, encodeURIComponent(String(requestParameters["buildSlug"]))),
1287
- method: "GET",
1288
- headers: headerParameters,
1289
- query: queryParameters
1290
- }, initOverrides);
1291
- if (this.isJsonMime(response.headers.get("content-type"))) {
1292
- return new JSONApiResponse(response);
1293
- } else {
1294
- return new TextApiResponse(response);
1295
- }
1296
- }
1297
- /**
1298
- * Get the bitrise.yml file of one of the builds of a given app. This will return the `bitrise.yml` configuration with which the build ran. You can compare it to [the current bitrise.yml configuration](https://api-docs.bitrise.io/#/application/app-config-datastore-show) of the app.
1299
- * Get the bitrise.yml of a build
1300
- */
1301
- async buildBitriseYmlShow(requestParameters, initOverrides) {
1302
- const response = await this.buildBitriseYmlShowRaw(requestParameters, initOverrides);
1303
- return await response.value();
1304
- }
1305
- /**
1306
- * List all the builds of a specified Bitrise app. Set parameters to filter builds: for example, you can search for builds run with a given workflow or all builds that were triggered by Pull Requests. It returns all the relevant data of the build.
1307
- * List all builds of an app
1308
- */
1309
- async buildListRaw(requestParameters, initOverrides) {
1310
- if (requestParameters["appSlug"] == null) {
1311
- throw new RequiredError(
1312
- "appSlug",
1313
- 'Required parameter "appSlug" was null or undefined when calling buildList().'
1314
- );
1315
- }
1316
- const queryParameters = {};
1317
- if (requestParameters["sortBy"] != null) {
1318
- queryParameters["sort_by"] = requestParameters["sortBy"];
1319
- }
1320
- if (requestParameters["branch"] != null) {
1321
- queryParameters["branch"] = requestParameters["branch"];
1322
- }
1323
- if (requestParameters["workflow"] != null) {
1324
- queryParameters["workflow"] = requestParameters["workflow"];
1325
- }
1326
- if (requestParameters["commitMessage"] != null) {
1327
- queryParameters["commit_message"] = requestParameters["commitMessage"];
1328
- }
1329
- if (requestParameters["triggerEventType"] != null) {
1330
- queryParameters["trigger_event_type"] = requestParameters["triggerEventType"];
1331
- }
1332
- if (requestParameters["pullRequestId"] != null) {
1333
- queryParameters["pull_request_id"] = requestParameters["pullRequestId"];
1334
- }
1335
- if (requestParameters["buildNumber"] != null) {
1336
- queryParameters["build_number"] = requestParameters["buildNumber"];
1337
- }
1338
- if (requestParameters["after"] != null) {
1339
- queryParameters["after"] = requestParameters["after"];
1340
- }
1341
- if (requestParameters["before"] != null) {
1342
- queryParameters["before"] = requestParameters["before"];
1343
- }
1344
- if (requestParameters["status"] != null) {
1345
- queryParameters["status"] = requestParameters["status"];
1346
- }
1347
- if (requestParameters["isPipelineBuild"] != null) {
1348
- queryParameters["is_pipeline_build"] = requestParameters["isPipelineBuild"];
1349
- }
1350
- if (requestParameters["next"] != null) {
1351
- queryParameters["next"] = requestParameters["next"];
1352
- }
1353
- if (requestParameters["limit"] != null) {
1354
- queryParameters["limit"] = requestParameters["limit"];
1355
- }
1356
- const headerParameters = {};
1357
- if (this.configuration && this.configuration.apiKey) {
1358
- headerParameters["Bitrise-Addon-Auth-Token"] = await this.configuration.apiKey("Bitrise-Addon-Auth-Token");
1359
- }
1360
- if (this.configuration && this.configuration.apiKey) {
1361
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
1362
- }
1363
- const response = await this.request({
1364
- path: `/apps/{app-slug}/builds`.replace(`{${"app-slug"}}`, encodeURIComponent(String(requestParameters["appSlug"]))),
1365
- method: "GET",
1366
- headers: headerParameters,
1367
- query: queryParameters
1368
- }, initOverrides);
1369
- return new JSONApiResponse(response, (jsonValue) => V0BuildListResponseModelFromJSON(jsonValue));
1370
- }
1371
- /**
1372
- * List all the builds of a specified Bitrise app. Set parameters to filter builds: for example, you can search for builds run with a given workflow or all builds that were triggered by Pull Requests. It returns all the relevant data of the build.
1373
- * List all builds of an app
1374
- */
1375
- async buildList(requestParameters, initOverrides) {
1376
- const response = await this.buildListRaw(requestParameters, initOverrides);
1377
- return await response.value();
1378
- }
1379
- /**
1380
- * List all the Bitrise builds that can be accessed with the authenticated account. Filter builds based on their owner, using the owner slug, or the status of the build.
1381
- * List all builds
1382
- */
1383
- async buildListAllRaw(requestParameters, initOverrides) {
1384
- const queryParameters = {};
1385
- if (requestParameters["ownerSlug"] != null) {
1386
- queryParameters["owner_slug"] = requestParameters["ownerSlug"];
1387
- }
1388
- if (requestParameters["isOnHold"] != null) {
1389
- queryParameters["is_on_hold"] = requestParameters["isOnHold"];
1390
- }
1391
- if (requestParameters["status"] != null) {
1392
- queryParameters["status"] = requestParameters["status"];
1393
- }
1394
- if (requestParameters["next"] != null) {
1395
- queryParameters["next"] = requestParameters["next"];
1396
- }
1397
- if (requestParameters["limit"] != null) {
1398
- queryParameters["limit"] = requestParameters["limit"];
1399
- }
1400
- const headerParameters = {};
1401
- if (this.configuration && this.configuration.apiKey) {
1402
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
1403
- }
1404
- const response = await this.request({
1405
- path: `/builds`,
1406
- method: "GET",
1407
- headers: headerParameters,
1408
- query: queryParameters
1409
- }, initOverrides);
1410
- return new JSONApiResponse(response, (jsonValue) => V0BuildListAllResponseModelFromJSON(jsonValue));
1411
- }
1412
- /**
1413
- * List all the Bitrise builds that can be accessed with the authenticated account. Filter builds based on their owner, using the owner slug, or the status of the build.
1414
- * List all builds
1415
- */
1416
- async buildListAll(requestParameters = {}, initOverrides) {
1417
- const response = await this.buildListAllRaw(requestParameters, initOverrides);
1418
- return await response.value();
1419
- }
1420
- /**
1421
- * Get the build log of a specified build of a Bitrise app. You can get the build slug either by calling the [/builds](https://api-docs.bitrise.io/#/builds/build-list) endpoint or by clicking on the build on bitrise.io and copying the slug from the URL. Preview of the log is returned in `log_chunks` field in JSON format. You can download the full raw log in txt by using the signed url returned in `expiring_raw_log_url`. Be aware that this url is expiring in 10 minutes!
1422
- * Get the build log of a build
1423
- */
1424
- async buildLogRaw(requestParameters, initOverrides) {
1425
- if (requestParameters["appSlug"] == null) {
1426
- throw new RequiredError(
1427
- "appSlug",
1428
- 'Required parameter "appSlug" was null or undefined when calling buildLog().'
1429
- );
1430
- }
1431
- if (requestParameters["buildSlug"] == null) {
1432
- throw new RequiredError(
1433
- "buildSlug",
1434
- 'Required parameter "buildSlug" was null or undefined when calling buildLog().'
1435
- );
1436
- }
1437
- const queryParameters = {};
1438
- const headerParameters = {};
1439
- if (this.configuration && this.configuration.apiKey) {
1440
- headerParameters["Bitrise-Addon-Auth-Token"] = await this.configuration.apiKey("Bitrise-Addon-Auth-Token");
1441
- }
1442
- if (this.configuration && this.configuration.apiKey) {
1443
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
1444
- }
1445
- const response = await this.request({
1446
- path: `/apps/{app-slug}/builds/{build-slug}/log`.replace(`{${"app-slug"}}`, encodeURIComponent(String(requestParameters["appSlug"]))).replace(`{${"build-slug"}}`, encodeURIComponent(String(requestParameters["buildSlug"]))),
1447
- method: "GET",
1448
- headers: headerParameters,
1449
- query: queryParameters
1450
- }, initOverrides);
1451
- return new VoidApiResponse(response);
1452
- }
1453
- /**
1454
- * Get the build log of a specified build of a Bitrise app. You can get the build slug either by calling the [/builds](https://api-docs.bitrise.io/#/builds/build-list) endpoint or by clicking on the build on bitrise.io and copying the slug from the URL. Preview of the log is returned in `log_chunks` field in JSON format. You can download the full raw log in txt by using the signed url returned in `expiring_raw_log_url`. Be aware that this url is expiring in 10 minutes!
1455
- * Get the build log of a build
1456
- */
1457
- async buildLog(requestParameters, initOverrides) {
1458
- await this.buildLogRaw(requestParameters, initOverrides);
1459
- }
1460
- /**
1461
- * Get the specified build of a given Bitrise app. You need to provide both an app slug and a build slug. You can get the build slug either by calling the [/builds](https://api-docs.bitrise.io/#/builds/build-list) endpoint or by clicking on the build on bitrise.io and copying the slug from the URL. The endpoint returns all the relevant data of the build.
1462
- * Get a build of a given app
1463
- */
1464
- async buildShowRaw(requestParameters, initOverrides) {
1465
- if (requestParameters["appSlug"] == null) {
1466
- throw new RequiredError(
1467
- "appSlug",
1468
- 'Required parameter "appSlug" was null or undefined when calling buildShow().'
1469
- );
1470
- }
1471
- if (requestParameters["buildSlug"] == null) {
1472
- throw new RequiredError(
1473
- "buildSlug",
1474
- 'Required parameter "buildSlug" was null or undefined when calling buildShow().'
1475
- );
1476
- }
1477
- const queryParameters = {};
1478
- const headerParameters = {};
1479
- if (this.configuration && this.configuration.apiKey) {
1480
- headerParameters["Bitrise-Addon-Auth-Token"] = await this.configuration.apiKey("Bitrise-Addon-Auth-Token");
1481
- }
1482
- if (this.configuration && this.configuration.apiKey) {
1483
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
1484
- }
1485
- const response = await this.request({
1486
- path: `/apps/{app-slug}/builds/{build-slug}`.replace(`{${"app-slug"}}`, encodeURIComponent(String(requestParameters["appSlug"]))).replace(`{${"build-slug"}}`, encodeURIComponent(String(requestParameters["buildSlug"]))),
1487
- method: "GET",
1488
- headers: headerParameters,
1489
- query: queryParameters
1490
- }, initOverrides);
1491
- return new JSONApiResponse(response, (jsonValue) => V0BuildShowResponseModelFromJSON(jsonValue));
1492
- }
1493
- /**
1494
- * Get the specified build of a given Bitrise app. You need to provide both an app slug and a build slug. You can get the build slug either by calling the [/builds](https://api-docs.bitrise.io/#/builds/build-list) endpoint or by clicking on the build on bitrise.io and copying the slug from the URL. The endpoint returns all the relevant data of the build.
1495
- * Get a build of a given app
1496
- */
1497
- async buildShow(requestParameters, initOverrides) {
1498
- const response = await this.buildShowRaw(requestParameters, initOverrides);
1499
- return await response.value();
1500
- }
1501
- /**
1502
- * Trigger a new build/pipeline. Specify an app slug and at least one parameter out of three: a git tag or git commit hash, a branch, or a workflow/pipeline ID. You can also set specific parameters for Pull Request builds/pipelines and define additional environment variables for your build/pipeline. [Check out our detailed guide](https://devcenter.bitrise.io/api/build-trigger/).
1503
- * Trigger a new build/pipeline
1504
- */
1505
- async buildTriggerRaw(requestParameters, initOverrides) {
1506
- if (requestParameters["appSlug"] == null) {
1507
- throw new RequiredError(
1508
- "appSlug",
1509
- 'Required parameter "appSlug" was null or undefined when calling buildTrigger().'
1510
- );
1511
- }
1512
- if (requestParameters["buildParams"] == null) {
1513
- throw new RequiredError(
1514
- "buildParams",
1515
- 'Required parameter "buildParams" was null or undefined when calling buildTrigger().'
1516
- );
1517
- }
1518
- const queryParameters = {};
1519
- const headerParameters = {};
1520
- headerParameters["Content-Type"] = "application/json";
1521
- if (this.configuration && this.configuration.apiKey) {
1522
- headerParameters["Bitrise-Addon-Auth-Token"] = await this.configuration.apiKey("Bitrise-Addon-Auth-Token");
1523
- }
1524
- if (this.configuration && this.configuration.apiKey) {
1525
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
1526
- }
1527
- const response = await this.request({
1528
- path: `/apps/{app-slug}/builds`.replace(`{${"app-slug"}}`, encodeURIComponent(String(requestParameters["appSlug"]))),
1529
- method: "POST",
1530
- headers: headerParameters,
1531
- query: queryParameters,
1532
- body: V0BuildTriggerParamsToJSON(requestParameters["buildParams"])
1533
- }, initOverrides);
1534
- return new JSONApiResponse(response, (jsonValue) => V0BuildTriggerRespModelFromJSON(jsonValue));
1535
- }
1536
- /**
1537
- * Trigger a new build/pipeline. Specify an app slug and at least one parameter out of three: a git tag or git commit hash, a branch, or a workflow/pipeline ID. You can also set specific parameters for Pull Request builds/pipelines and define additional environment variables for your build/pipeline. [Check out our detailed guide](https://devcenter.bitrise.io/api/build-trigger/).
1538
- * Trigger a new build/pipeline
1539
- */
1540
- async buildTrigger(requestParameters, initOverrides) {
1541
- const response = await this.buildTriggerRaw(requestParameters, initOverrides);
1542
- return await response.value();
1543
- }
1544
- /**
1545
- * List the workflows that were triggered at any time for a given Bitrise app. Note that it might list workflows that are currently not defined in the app\'s `bitrise.yml` configuration - and conversely, workflows that were never triggered will not be listed even if they are defined in the `bitrise.yml` file.
1546
- * List the workflows of an app
1547
- */
1548
- async buildWorkflowListRaw(requestParameters, initOverrides) {
1549
- if (requestParameters["appSlug"] == null) {
1550
- throw new RequiredError(
1551
- "appSlug",
1552
- 'Required parameter "appSlug" was null or undefined when calling buildWorkflowList().'
1553
- );
1554
- }
1555
- const queryParameters = {};
1556
- const headerParameters = {};
1557
- if (this.configuration && this.configuration.apiKey) {
1558
- headerParameters["Bitrise-Addon-Auth-Token"] = await this.configuration.apiKey("Bitrise-Addon-Auth-Token");
1559
- }
1560
- if (this.configuration && this.configuration.apiKey) {
1561
- headerParameters["Authorization"] = await this.configuration.apiKey("Authorization");
1562
- }
1563
- const response = await this.request({
1564
- path: `/apps/{app-slug}/build-workflows`.replace(`{${"app-slug"}}`, encodeURIComponent(String(requestParameters["appSlug"]))),
1565
- method: "GET",
1566
- headers: headerParameters,
1567
- query: queryParameters
1568
- }, initOverrides);
1569
- return new JSONApiResponse(response, (jsonValue) => V0BuildWorkflowListResponseModelFromJSON(jsonValue));
1570
- }
1571
- /**
1572
- * List the workflows that were triggered at any time for a given Bitrise app. Note that it might list workflows that are currently not defined in the app\'s `bitrise.yml` configuration - and conversely, workflows that were never triggered will not be listed even if they are defined in the `bitrise.yml` file.
1573
- * List the workflows of an app
1574
- */
1575
- async buildWorkflowList(requestParameters, initOverrides) {
1576
- const response = await this.buildWorkflowListRaw(requestParameters, initOverrides);
1577
- return await response.value();
1578
- }
1579
- };
1580
-
1581
- // src/bitrise/api.ts
1582
- var apiConfig = new Configuration({ apiKey: () => ENV.token });
1583
- var apiBuildArtifact = new BuildArtifactApi(apiConfig);
1584
- var apiBuilds = new BuildsApi(apiConfig);
1585
-
1586
- // src/helper/debugLog.ts
1587
- var debugLog = (label, data) => console.log(`${label}: ${JSON.stringify(data, void 0, 2)}`);
1588
-
1589
- // src/helper/ensureMandatoryFields.ts
1590
- var ensureMandatoryFields = (input, mandatory) => {
1591
- for (const field of mandatory) {
1592
- if (!input[field]) throw new Error(`Missing mandatory field: ${String(field)}`);
1593
- }
1594
- return input;
1595
- };
1596
-
1597
- // src/bitrise/fetchArtifact.ts
1598
- var fetchArtifact = async ({ artifactSlug, buildSlug }) => {
1599
- const { data } = await apiBuildArtifact.artifactShow({ appSlug: ENV.appSlug, artifactSlug, buildSlug });
1600
- if (!data) throw new Error("buildArtifact().artifactShow returned no data");
1601
- if (ENV.debug) debugLog("artifact", data);
1602
- return ensureMandatoryFields(data, ["expiringDownloadUrl"]);
1603
- };
1604
-
1605
- // src/bitrise/fetchArtifactList.ts
1606
- var fetchArtifactList = async (buildSlug) => {
1607
- const { data } = await apiBuildArtifact.artifactList({ appSlug: ENV.appSlug, buildSlug });
1608
- if (!data) throw new Error("buildArtifact().artifactList returned no data");
1609
- return data;
1610
- };
1611
- var fetchArtifactByType = async (buildSlug) => {
1612
- const artifactInfo = await fetchArtifactList(buildSlug);
1613
- const artifactMetadata = artifactInfo.find((artifact) => artifact.artifactType === ENV.artifactType);
1614
- if (ENV.debug) debugLog("artifactMetadata", artifactMetadata);
1615
- if (!artifactMetadata) throw new Error(`Found no ${ENV.artifactType} in build Slug: ${buildSlug}`);
1616
- return ensureMandatoryFields(artifactMetadata, ["slug", "title"]);
1617
- };
1618
-
1619
- // src/bitrise/fetchBuilds.ts
1620
- var getAllBuilds = async () => {
1621
- const { data } = await apiBuilds.buildList({ appSlug: ENV.appSlug, status: 1 });
1622
- if (!data) throw Error("no build data");
1623
- return data;
1624
- };
1625
- var getLatestBuild = async () => {
1626
- const builds = await getAllBuilds();
1627
- const latestBuild = builds.find((build) => build.triggeredWorkflow === ENV.workflow);
1628
- if (!latestBuild) throw `Found no build with the workflow: "${ENV.workflow}"`;
1629
- if (ENV.debug) debugLog("latestBuild", latestBuild);
1630
- return ensureMandatoryFields(latestBuild, ["slug"]);
1631
- };
1632
-
1633
- // src/helper/downloadFile.ts
1634
- import { createWriteStream } from "node:fs";
1635
- import { get } from "node:https";
1636
- import { pipeline } from "node:stream/promises";
1637
- import { URL } from "node:url";
1638
- var downloadFile = async (fileUrl, outputLocationPath) => {
1639
- const startTime = Date.now();
1640
- const url = new URL(fileUrl);
1641
- const response = await new Promise((resolve, reject) => {
1642
- get(url, (res) => {
1643
- if (res.statusCode !== 200) {
1644
- reject(new Error(`Failed to get '${fileUrl}' (${res.statusCode})`));
1645
- } else {
1646
- resolve(res);
1647
- }
1648
- }).on("error", reject);
1649
- });
1650
- await pipeline(response, createWriteStream(outputLocationPath));
1651
- return { file: outputLocationPath, duration: Date.now() - startTime };
1652
- };
1653
-
1654
- // src/helper/formatBytes.ts
1655
- var decimals = 0;
1656
- var formatBytes = (bytes) => {
1657
- if (bytes === 0) return "0 Bytes";
1658
- const k = 1024;
1659
- const dm = decimals || 2;
1660
- const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
1661
- const i = Math.floor(Math.log(bytes) / Math.log(k));
1662
- const formattedSize = Number.parseFloat((bytes / k ** i).toFixed(dm));
1663
- return `${formattedSize} ${sizes[i]}`;
1664
- };
1665
-
1666
- // src/downloadLatestArtifacts.ts
1667
- import { oraPromise as oraPromise3 } from "ora";
1668
- var downloadLatestArtifacts = async (options) => {
1669
- const latestBuild = await oraPromise3(getLatestBuild(), getOraTexts("fetching latest build"));
1670
- const artifactMetadata = await oraPromise3(
1671
- fetchArtifactByType(latestBuild.slug),
1672
- getOraTexts("fetching artifact list")
1673
- );
1674
- const artifact = await oraPromise3(
1675
- fetchArtifact({ artifactSlug: artifactMetadata.slug, buildSlug: latestBuild.slug }),
1676
- getOraTexts("fetching artifact metadata")
1677
- );
1678
- const fileType = artifact.title?.split(".").pop() ?? "unknown";
1679
- const { file } = await oraPromise3(downloadFile(artifact.expiringDownloadUrl, artifactMetadata.title), {
1680
- ...getOraTexts(`downloading ${fileType} file`),
1681
- text: `downloading ${fileType} file [${formatBytes(artifact.fileSizeBytes ?? 0)}]`
1682
- });
1683
- return file;
1684
- };
1685
-
1686
- // src/cli/commands/download/impl.ts
1687
- async function impl_default(flags) {
1688
- if (!setupEnv(flags)) return process.exit(1);
1689
- const file = await downloadLatestArtifacts(flags);
1690
- if (flags.install) {
1691
- await installApp({ file, flags });
1692
- }
1693
- }
1694
- export {
1695
- impl_default as default
1696
- };