@argos-ci/api-client 0.5.0 → 0.6.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.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { FetchResponse } from "openapi-fetch";
2
1
  /**
3
2
  * This file was auto-generated by openapi-typescript.
4
3
  * Do not make direct changes to the file.
@@ -233,6 +232,7 @@ interface operations {
233
232
  prHeadCommit?: string | null;
234
233
  referenceCommit?: string | null;
235
234
  referenceBranch?: string | null;
235
+ parentCommits?: components["schemas"]["Sha1Hash"][] | null;
236
236
  /** @enum {string|null} */
237
237
  mode?: "ci" | "monitoring" | null;
238
238
  ciProvider?: string | null;
@@ -807,6 +807,7 @@ declare namespace ArgosAPISchema {
807
807
  prHeadCommit?: string | null;
808
808
  referenceCommit?: string | null;
809
809
  referenceBranch?: string | null;
810
+ parentCommits?: components["schemas"]["Sha1Hash"][] | null;
810
811
  /** @enum {string|null} */
811
812
  mode?: "ci" | "monitoring" | null;
812
813
  ciProvider?: string | null;
@@ -1159,5 +1160,10 @@ declare class APIError extends Error {
1159
1160
  /**
1160
1161
  * Handle API errors.
1161
1162
  */
1162
- declare function throwAPIError(fetchResponse: FetchResponse<any, any, any>): never;
1163
+ declare function throwAPIError(error: {
1164
+ error: string;
1165
+ details: {
1166
+ message: string;
1167
+ }[];
1168
+ }): never;
1163
1169
  export { ArgosAPISchema, ArgosAPIClient, createClient, APIError, throwAPIError };
package/dist/index.mjs CHANGED
@@ -1,4 +1,8 @@
1
1
  import createFetchClient from 'openapi-fetch';
2
+ import createDebug from 'debug';
3
+
4
+ const KEY = "@argos-ci/api-client";
5
+ const debug = createDebug(KEY);
2
6
 
3
7
  var schema = /*#__PURE__*/Object.freeze({
4
8
  __proto__: null
@@ -22,12 +26,10 @@ class APIError extends Error {
22
26
  }
23
27
  /**
24
28
  * Handle API errors.
25
- */ function throwAPIError(fetchResponse) {
26
- const { error, response } = fetchResponse;
27
- if (error && typeof error === "object" && "error" in error && typeof error.error === "string") {
28
- throw new APIError(error.error);
29
- }
30
- throw new APIError(`API error: ${response.status} ${response.statusText}`);
29
+ */ function throwAPIError(error) {
30
+ debug("API error", error);
31
+ const detailMessage = error.details.map((detail)=>detail.message).join(", ");
32
+ throw new APIError(`${error.error}: ${detailMessage}`);
31
33
  }
32
34
 
33
35
  export { APIError, schema as ArgosAPISchema, createClient, throwAPIError };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/api-client",
3
3
  "description": "Argos API client.",
4
- "version": "0.5.0",
4
+ "version": "0.6.0",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -42,11 +42,13 @@
42
42
  "build": "rollup -c"
43
43
  },
44
44
  "devDependencies": {
45
+ "@types/debug": "^4.1.12",
45
46
  "@types/node": "^18.19.44",
46
47
  "openapi-typescript": "^7.3.0"
47
48
  },
48
49
  "dependencies": {
50
+ "debug": "^4.3.6",
49
51
  "openapi-fetch": "^0.11.1"
50
52
  },
51
- "gitHead": "682860bc510fc3c2afcdd3335236c463ccce2783"
53
+ "gitHead": "cae12b0cb7d4e9237cf5973d7911af68bc708773"
52
54
  }