@argos-ci/api-client 0.20.1 → 0.21.0
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
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import * as _$openapi_fetch0 from "openapi-fetch";
|
|
2
|
-
|
|
3
|
-
//#region src/schema.d.ts
|
|
4
1
|
declare namespace schema_d_exports {
|
|
5
2
|
export { $defs, components, operations, paths, webhooks };
|
|
6
3
|
}
|
|
@@ -1656,7 +1653,7 @@ type ArgosAPIClient = ReturnType<typeof createClient>;
|
|
|
1656
1653
|
declare function createClient(options?: {
|
|
1657
1654
|
baseUrl?: string;
|
|
1658
1655
|
authToken?: string;
|
|
1659
|
-
}):
|
|
1656
|
+
}): import("openapi-fetch").Client<paths, `${string}/${string}`>;
|
|
1660
1657
|
/**
|
|
1661
1658
|
* Handle API errors.
|
|
1662
1659
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as __exportAll } from "./chunk-
|
|
1
|
+
import { t as __exportAll } from "./chunk-D7D4PA-g.mjs";
|
|
2
2
|
import createFetchClient from "openapi-fetch";
|
|
3
3
|
import createDebug from "debug";
|
|
4
4
|
import pRetry from "p-retry";
|
|
@@ -14,27 +14,33 @@ var APIError = class extends Error {
|
|
|
14
14
|
async function createRequestFactory(request, timeout) {
|
|
15
15
|
const body = request.body ? await request.arrayBuffer() : void 0;
|
|
16
16
|
const headers = new Headers(request.headers);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
const requestId = headers.get("x-argos-request-id")?.trim() || globalThis.crypto.randomUUID();
|
|
18
|
+
return (retryAttempt) => {
|
|
19
|
+
const requestHeaders = new Headers(headers);
|
|
20
|
+
requestHeaders.set("x-argos-request-id", requestId);
|
|
21
|
+
requestHeaders.set("x-argos-retry-attempt", String(retryAttempt));
|
|
22
|
+
return new Request(request.url, {
|
|
23
|
+
body,
|
|
24
|
+
cache: request.cache,
|
|
25
|
+
credentials: request.credentials,
|
|
26
|
+
headers: requestHeaders,
|
|
27
|
+
integrity: request.integrity,
|
|
28
|
+
keepalive: request.keepalive,
|
|
29
|
+
method: request.method,
|
|
30
|
+
mode: request.mode,
|
|
31
|
+
redirect: request.redirect,
|
|
32
|
+
referrer: request.referrer,
|
|
33
|
+
referrerPolicy: request.referrerPolicy,
|
|
34
|
+
signal: AbortSignal.any([request.signal, AbortSignal.timeout(timeout)])
|
|
35
|
+
});
|
|
36
|
+
};
|
|
31
37
|
}
|
|
32
38
|
async function apiFetch(input, options = {}) {
|
|
33
39
|
input.signal.throwIfAborted();
|
|
34
40
|
const fetchImpl = options.fetch ?? fetch;
|
|
35
41
|
const createRequest = await createRequestFactory(input, options.timeout ?? DEFAULT_TIMEOUT);
|
|
36
|
-
return pRetry(async () => {
|
|
37
|
-
const response = await fetchImpl(createRequest());
|
|
42
|
+
return pRetry(async (attemptNumber) => {
|
|
43
|
+
const response = await fetchImpl(createRequest(attemptNumber - 1));
|
|
38
44
|
if (response.status >= 500) throw new APIError(`Internal Server Error (${response.status})`);
|
|
39
45
|
return response;
|
|
40
46
|
}, {
|
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.21.0",
|
|
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": "fa5a1d192b0782602f9a415ddfc82c0f696eec7b"
|
|
58
58
|
}
|
|
File without changes
|