@argos-ci/api-client 0.21.0 → 0.22.1
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/dist/index.d.mts
CHANGED
|
@@ -280,7 +280,11 @@ interface components {
|
|
|
280
280
|
schemas: {
|
|
281
281
|
/** @description SHA1 hash */Sha1Hash: string;
|
|
282
282
|
GitBranch: string; /** @description SHA256 hash */
|
|
283
|
-
Sha256Hash: string;
|
|
283
|
+
Sha256Hash: string; /** @description Screenshot file to upload */
|
|
284
|
+
ScreenshotUploadRequest: {
|
|
285
|
+
key: components["schemas"]["Sha256Hash"]; /** @description Content type of the snapshot file */
|
|
286
|
+
contentType: string;
|
|
287
|
+
};
|
|
284
288
|
/**
|
|
285
289
|
* @description A unique identifier for the build
|
|
286
290
|
* @example 12345
|
|
@@ -349,8 +353,8 @@ interface components {
|
|
|
349
353
|
tags?: string[];
|
|
350
354
|
} | null;
|
|
351
355
|
pwTraceKey?: string | null;
|
|
352
|
-
threshold?: number | null; /** @
|
|
353
|
-
contentType
|
|
356
|
+
threshold?: number | null; /** @description Content type of the snapshot file */
|
|
357
|
+
contentType?: string;
|
|
354
358
|
}; /** @description Build metadata */
|
|
355
359
|
BuildMetadata: {
|
|
356
360
|
/** @description Test suite report */testReport?: {
|
|
@@ -413,7 +417,8 @@ interface components {
|
|
|
413
417
|
};
|
|
414
418
|
gitlab: {
|
|
415
419
|
/** @enum {string} */state: "pending" | "running" | "success" | "failed" | "canceled";
|
|
416
|
-
};
|
|
420
|
+
}; /** Format: uri */
|
|
421
|
+
url: string;
|
|
417
422
|
} | null;
|
|
418
423
|
}; /** @description Git reference */
|
|
419
424
|
BuildGitReference: {
|
|
@@ -618,8 +623,7 @@ interface operations {
|
|
|
618
623
|
content: {
|
|
619
624
|
"application/json": {
|
|
620
625
|
/** @description The commit the build is running on */commit: components["schemas"]["Sha1Hash"]; /** @description The branch the build is running on */
|
|
621
|
-
branch: components["schemas"]["GitBranch"]; /** @description Keys of
|
|
622
|
-
screenshotKeys: components["schemas"]["Sha256Hash"][]; /** @description Keys of Playwright trace files */
|
|
626
|
+
branch: components["schemas"]["GitBranch"]; /** @description Keys of Playwright trace files */
|
|
623
627
|
pwTraceKeys?: components["schemas"]["Sha256Hash"][]; /** @description The name of the build (for multi-build setups) */
|
|
624
628
|
name?: string | null; /** @description Whether to run the build in parallel */
|
|
625
629
|
parallel?: boolean | null; /** @description A unique nonce for the parallel build */
|
|
@@ -642,7 +646,17 @@ interface operations {
|
|
|
642
646
|
* This is useful when a build is created from an incomplete test suite where some tests are skipped.
|
|
643
647
|
*/
|
|
644
648
|
subset?: boolean | null;
|
|
645
|
-
}
|
|
649
|
+
} & ({
|
|
650
|
+
/**
|
|
651
|
+
* @deprecated
|
|
652
|
+
* @description Keys of screenshot files
|
|
653
|
+
*/
|
|
654
|
+
screenshotKeys: components["schemas"]["Sha256Hash"][];
|
|
655
|
+
screenshots?: unknown;
|
|
656
|
+
} | {
|
|
657
|
+
/** @description Screenshot files to upload */screenshots: components["schemas"]["ScreenshotUploadRequest"][];
|
|
658
|
+
screenshotKeys?: unknown;
|
|
659
|
+
});
|
|
646
660
|
};
|
|
647
661
|
};
|
|
648
662
|
responses: {
|
|
@@ -653,14 +667,36 @@ interface operations {
|
|
|
653
667
|
content: {
|
|
654
668
|
"application/json": {
|
|
655
669
|
build: components["schemas"]["Build"];
|
|
656
|
-
screenshots: {
|
|
657
|
-
key: string;
|
|
670
|
+
screenshots: ({
|
|
671
|
+
key: string;
|
|
672
|
+
/**
|
|
673
|
+
* Format: uri
|
|
674
|
+
* @deprecated
|
|
675
|
+
* @description Deprecated. Use postUrl and fields instead.
|
|
676
|
+
*/
|
|
658
677
|
putUrl: string;
|
|
659
|
-
}
|
|
660
|
-
pwTraces: {
|
|
678
|
+
} | {
|
|
661
679
|
key: string; /** Format: uri */
|
|
680
|
+
postUrl: string;
|
|
681
|
+
fields: {
|
|
682
|
+
[key: string]: string;
|
|
683
|
+
};
|
|
684
|
+
})[];
|
|
685
|
+
pwTraces: ({
|
|
686
|
+
key: string;
|
|
687
|
+
/**
|
|
688
|
+
* Format: uri
|
|
689
|
+
* @deprecated
|
|
690
|
+
* @description Deprecated. Use postUrl and fields instead.
|
|
691
|
+
*/
|
|
662
692
|
putUrl: string;
|
|
663
|
-
}
|
|
693
|
+
} | {
|
|
694
|
+
key: string; /** Format: uri */
|
|
695
|
+
postUrl: string;
|
|
696
|
+
fields: {
|
|
697
|
+
[key: string]: string;
|
|
698
|
+
};
|
|
699
|
+
})[];
|
|
664
700
|
};
|
|
665
701
|
};
|
|
666
702
|
}; /** @description Invalid parameters */
|
|
@@ -1181,6 +1217,14 @@ interface operations {
|
|
|
1181
1217
|
content: {
|
|
1182
1218
|
"application/json": components["schemas"]["Error"];
|
|
1183
1219
|
};
|
|
1220
|
+
}; /** @description Not found */
|
|
1221
|
+
404: {
|
|
1222
|
+
headers: {
|
|
1223
|
+
[name: string]: unknown;
|
|
1224
|
+
};
|
|
1225
|
+
content: {
|
|
1226
|
+
"application/json": components["schemas"]["Error"];
|
|
1227
|
+
};
|
|
1184
1228
|
}; /** @description Server error */
|
|
1185
1229
|
500: {
|
|
1186
1230
|
headers: {
|
|
@@ -1189,6 +1233,14 @@ interface operations {
|
|
|
1189
1233
|
content: {
|
|
1190
1234
|
"application/json": components["schemas"]["Error"];
|
|
1191
1235
|
};
|
|
1236
|
+
}; /** @description Service unavailable */
|
|
1237
|
+
503: {
|
|
1238
|
+
headers: {
|
|
1239
|
+
[name: string]: unknown;
|
|
1240
|
+
};
|
|
1241
|
+
content: {
|
|
1242
|
+
"application/json": components["schemas"]["Error"];
|
|
1243
|
+
};
|
|
1192
1244
|
};
|
|
1193
1245
|
};
|
|
1194
1246
|
};
|
|
@@ -1573,10 +1625,17 @@ interface operations {
|
|
|
1573
1625
|
content: {
|
|
1574
1626
|
"application/json": {
|
|
1575
1627
|
/**
|
|
1576
|
-
* @description
|
|
1628
|
+
* @description Review event to apply to the build: "APPROVE", "REJECT" or "COMMENT". Required when `conclusion` is not provided.
|
|
1629
|
+
* @enum {string}
|
|
1630
|
+
*/
|
|
1631
|
+
event?: "APPROVE" | "REJECT" | "COMMENT";
|
|
1632
|
+
/**
|
|
1633
|
+
* @deprecated
|
|
1634
|
+
* @description Deprecated: use `event` instead. Overall review conclusion for the build: "APPROVE" or "REQUEST_CHANGES".
|
|
1577
1635
|
* @enum {string}
|
|
1578
1636
|
*/
|
|
1579
|
-
conclusion
|
|
1637
|
+
conclusion?: "APPROVE" | "REQUEST_CHANGES"; /** @description Optional comment to attach to the review. Expected as the JSON representation of a rich-text document. */
|
|
1638
|
+
body?: unknown;
|
|
1580
1639
|
/**
|
|
1581
1640
|
* @description Optional per-snapshot review decisions. When omitted, only the build-level review is recorded.
|
|
1582
1641
|
* @default []
|
|
@@ -1600,9 +1659,17 @@ interface operations {
|
|
|
1600
1659
|
content: {
|
|
1601
1660
|
"application/json": {
|
|
1602
1661
|
id: string; /** @enum {string} */
|
|
1603
|
-
state: "approved" | "rejected";
|
|
1662
|
+
state: "approved" | "rejected" | "commented" | "pending";
|
|
1604
1663
|
};
|
|
1605
1664
|
};
|
|
1665
|
+
}; /** @description Invalid parameters */
|
|
1666
|
+
400: {
|
|
1667
|
+
headers: {
|
|
1668
|
+
[name: string]: unknown;
|
|
1669
|
+
};
|
|
1670
|
+
content: {
|
|
1671
|
+
"application/json": components["schemas"]["Error"];
|
|
1672
|
+
};
|
|
1606
1673
|
}; /** @description Unauthorized */
|
|
1607
1674
|
401: {
|
|
1608
1675
|
headers: {
|
|
@@ -1642,7 +1709,20 @@ interface operations {
|
|
|
1642
1709
|
//#endregion
|
|
1643
1710
|
//#region src/fetch.d.ts
|
|
1644
1711
|
declare class APIError extends Error {
|
|
1645
|
-
|
|
1712
|
+
/**
|
|
1713
|
+
* HTTP status code of the response that triggered the error, when available.
|
|
1714
|
+
*/
|
|
1715
|
+
status?: number;
|
|
1716
|
+
/**
|
|
1717
|
+
* Raw error payload returned by the API (or the infrastructure in front of
|
|
1718
|
+
* it). Useful when the body does not match the expected error shape.
|
|
1719
|
+
*/
|
|
1720
|
+
data?: unknown;
|
|
1721
|
+
constructor(message: string, options?: {
|
|
1722
|
+
status?: number;
|
|
1723
|
+
data?: unknown;
|
|
1724
|
+
cause?: unknown;
|
|
1725
|
+
});
|
|
1646
1726
|
}
|
|
1647
1727
|
//#endregion
|
|
1648
1728
|
//#region src/index.d.ts
|
|
@@ -1655,12 +1735,19 @@ declare function createClient(options?: {
|
|
|
1655
1735
|
authToken?: string;
|
|
1656
1736
|
}): import("openapi-fetch").Client<paths, `${string}/${string}`>;
|
|
1657
1737
|
/**
|
|
1658
|
-
*
|
|
1738
|
+
* Format an API error into a human-readable message.
|
|
1739
|
+
*
|
|
1740
|
+
* When the body matches the expected `{ error, details }` shape, it is used
|
|
1741
|
+
* directly. Otherwise — empty body, HTML error page, plain text, etc., which
|
|
1742
|
+
* happens when the response comes from infrastructure in front of the API
|
|
1743
|
+
* (proxy, load balancer, CDN, rate limiter) rather than from the API itself —
|
|
1744
|
+
* we fall back to the HTTP status and the raw body so the failure stays
|
|
1745
|
+
* debuggable instead of surfacing an empty message.
|
|
1659
1746
|
*/
|
|
1660
|
-
declare function formatAPIError(error:
|
|
1747
|
+
declare function formatAPIError(error: unknown, response?: Response): string;
|
|
1661
1748
|
/**
|
|
1662
1749
|
* Handle API errors.
|
|
1663
1750
|
*/
|
|
1664
|
-
declare function throwAPIError(error:
|
|
1751
|
+
declare function throwAPIError(error: unknown, response?: Response): never;
|
|
1665
1752
|
//#endregion
|
|
1666
1753
|
export { APIError, ArgosAPIClient, schema_d_exports as ArgosAPISchema, createClient, formatAPIError, throwAPIError };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __exportAll } from "./
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
2
|
import createFetchClient from "openapi-fetch";
|
|
3
3
|
import createDebug from "debug";
|
|
4
4
|
import pRetry from "p-retry";
|
|
@@ -7,8 +7,20 @@ const debug = createDebug("@argos-ci/api-client");
|
|
|
7
7
|
//#region src/fetch.ts
|
|
8
8
|
const DEFAULT_TIMEOUT = 3e4;
|
|
9
9
|
var APIError = class extends Error {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* HTTP status code of the response that triggered the error, when available.
|
|
12
|
+
*/
|
|
13
|
+
status;
|
|
14
|
+
/**
|
|
15
|
+
* Raw error payload returned by the API (or the infrastructure in front of
|
|
16
|
+
* it). Useful when the body does not match the expected error shape.
|
|
17
|
+
*/
|
|
18
|
+
data;
|
|
19
|
+
constructor(message, options) {
|
|
20
|
+
super(message, options?.cause != null ? { cause: options.cause } : void 0);
|
|
21
|
+
this.name = "APIError";
|
|
22
|
+
this.status = options?.status;
|
|
23
|
+
this.data = options?.data;
|
|
12
24
|
}
|
|
13
25
|
};
|
|
14
26
|
async function createRequestFactory(request, timeout) {
|
|
@@ -70,18 +82,70 @@ function createClient(options) {
|
|
|
70
82
|
});
|
|
71
83
|
}
|
|
72
84
|
/**
|
|
73
|
-
*
|
|
85
|
+
* Maximum length of a raw error body included in the formatted message.
|
|
86
|
+
* Keeps things readable when the body is an HTML error page or a stack trace.
|
|
87
|
+
*/
|
|
88
|
+
const MAX_RAW_BODY_LENGTH = 500;
|
|
89
|
+
/**
|
|
90
|
+
* Check whether the value matches the expected API error shape:
|
|
91
|
+
* `{ error: string, details?: [{ message }] }`.
|
|
92
|
+
*/
|
|
93
|
+
function isStructuredAPIError(error) {
|
|
94
|
+
return typeof error === "object" && error !== null && "error" in error && typeof error.error === "string" && error.error.length > 0;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Format the HTTP status of a response, e.g. `HTTP 413 Payload Too Large`.
|
|
98
|
+
*/
|
|
99
|
+
function formatStatus(response) {
|
|
100
|
+
if (!response) return null;
|
|
101
|
+
return response.statusText ? `HTTP ${response.status} ${response.statusText}` : `HTTP ${response.status}`;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Format a raw (non-structured) error body so it can be shown to the user.
|
|
105
|
+
* Returns `null` when there is nothing meaningful to display.
|
|
106
|
+
*/
|
|
107
|
+
function formatRawBody(error) {
|
|
108
|
+
if (error == null) return null;
|
|
109
|
+
let text;
|
|
110
|
+
if (typeof error === "string") text = error;
|
|
111
|
+
else try {
|
|
112
|
+
text = JSON.stringify(error);
|
|
113
|
+
} catch {
|
|
114
|
+
text = String(error);
|
|
115
|
+
}
|
|
116
|
+
const trimmed = text.trim();
|
|
117
|
+
if (!trimmed || trimmed === "{}") return null;
|
|
118
|
+
return trimmed.length > MAX_RAW_BODY_LENGTH ? `${trimmed.slice(0, MAX_RAW_BODY_LENGTH)}…` : trimmed;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Format an API error into a human-readable message.
|
|
122
|
+
*
|
|
123
|
+
* When the body matches the expected `{ error, details }` shape, it is used
|
|
124
|
+
* directly. Otherwise — empty body, HTML error page, plain text, etc., which
|
|
125
|
+
* happens when the response comes from infrastructure in front of the API
|
|
126
|
+
* (proxy, load balancer, CDN, rate limiter) rather than from the API itself —
|
|
127
|
+
* we fall back to the HTTP status and the raw body so the failure stays
|
|
128
|
+
* debuggable instead of surfacing an empty message.
|
|
74
129
|
*/
|
|
75
|
-
function formatAPIError(error) {
|
|
76
|
-
debug("API error",
|
|
77
|
-
|
|
78
|
-
|
|
130
|
+
function formatAPIError(error, response) {
|
|
131
|
+
debug("API error", {
|
|
132
|
+
error,
|
|
133
|
+
status: response?.status
|
|
134
|
+
});
|
|
135
|
+
if (isStructuredAPIError(error)) {
|
|
136
|
+
const detailMessage = error.details?.map((detail) => detail.message).join(", ");
|
|
137
|
+
return detailMessage ? `${error.error}: ${detailMessage}` : error.error;
|
|
138
|
+
}
|
|
139
|
+
return [formatStatus(response), formatRawBody(error)].filter(Boolean).join(": ") || "Unknown API error";
|
|
79
140
|
}
|
|
80
141
|
/**
|
|
81
142
|
* Handle API errors.
|
|
82
143
|
*/
|
|
83
|
-
function throwAPIError(error) {
|
|
84
|
-
throw new APIError(formatAPIError(error)
|
|
144
|
+
function throwAPIError(error, response) {
|
|
145
|
+
throw new APIError(formatAPIError(error, response), {
|
|
146
|
+
status: response?.status,
|
|
147
|
+
data: error
|
|
148
|
+
});
|
|
85
149
|
}
|
|
86
150
|
//#endregion
|
|
87
151
|
export { APIError, schema_exports as ArgosAPISchema, createClient, formatAPIError, throwAPIError };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/api-client",
|
|
3
3
|
"description": "Argos API Client library.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.22.1",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"openapi-fetch": "^0.17.0",
|
|
55
55
|
"p-retry": "^8.0.0"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "5bcfacce28cbe061590665bf5dec220439c8aebc"
|
|
58
58
|
}
|
|
File without changes
|