@mittwald/cli 1.0.0-alpha.44 → 1.0.0-alpha.45

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/README.md CHANGED
@@ -1997,7 +1997,7 @@ EXAMPLES
1997
1997
  $ mw autocomplete --refresh-cache
1998
1998
  ```
1999
1999
 
2000
- _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.0.17/src/commands/autocomplete/index.ts)_
2000
+ _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.0.18/src/commands/autocomplete/index.ts)_
2001
2001
 
2002
2002
  ## `mw backup create`
2003
2003
 
@@ -3768,7 +3768,7 @@ DESCRIPTION
3768
3768
  Display help for mw.
3769
3769
  ```
3770
3770
 
3771
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.21/src/commands/help.ts)_
3771
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.22/src/commands/help.ts)_
3772
3772
 
3773
3773
  ## `mw login reset`
3774
3774
 
@@ -1,6 +1,6 @@
1
- import { ApiClientError } from "@mittwald/api-client-commons";
1
+ import { AxiosError } from "@mittwald/api-client-commons";
2
2
  interface APIErrorProps {
3
- err: ApiClientError;
3
+ err: AxiosError;
4
4
  withStack: boolean;
5
5
  withHTTPMessages: "no" | "body" | "full";
6
6
  }
@@ -1,8 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Text } from "ink";
3
3
  import ErrorStack from "./ErrorStack.js";
4
4
  import ErrorText from "./ErrorText.js";
5
5
  import ErrorBox from "./ErrorBox.js";
6
+ import { SingleResultTable } from "../SingleResult.js";
7
+ import { Value } from "../Value.js";
6
8
  function RequestHeaders({ headers }) {
7
9
  const lines = headers.trim().split("\r\n");
8
10
  const requestLine = lines.shift();
@@ -19,11 +21,21 @@ function HttpMessages({ err }) {
19
21
  const response = err.response ? (_jsx(Response, { status: err.response.status, statusText: err.response.statusText, body: err.response.data, headers: err.response.headers })) : (_jsx(Text, { children: "no response received" }));
20
22
  return (_jsxs(Box, { marginX: 2, marginY: 1, flexDirection: "column", rowGap: 1, children: [_jsx(RequestHeaders, { headers: err.request._header }), response] }));
21
23
  }
24
+ function ErrorDetails({ err }) {
25
+ const errorBody = err.response?.data;
26
+ return (_jsx(SingleResultTable, { rows: {
27
+ Request: (_jsxs(Value, { bold: true, children: [err.config?.method?.toUpperCase(), " ", err.config?.url] })),
28
+ Response: (_jsxs(Value, { bold: true, children: [err.response?.status, " ", err.response?.statusText] })),
29
+ "Error Type": _jsx(Value, { bold: true, children: errorBody?.type }),
30
+ Message: _jsx(Value, { bold: true, children: errorBody?.message }),
31
+ "Trace ID": _jsx(Value, { bold: true, children: errorBody?.params?.["traceId"] }),
32
+ } }));
33
+ }
22
34
  /**
23
35
  * Render an API client error to the terminal. In the case of an API client
24
36
  * error, the error message will be displayed, as well as (when enabled) the
25
37
  * request and response headers and body.
26
38
  */
27
39
  export default function APIError({ err, withStack, withHTTPMessages, }) {
28
- return (_jsxs(_Fragment, { children: [_jsxs(ErrorBox, { children: [_jsx(ErrorText, { bold: true, underline: true, children: "API CLIENT ERROR" }), _jsxs(ErrorText, { children: ["An error occurred while communicating with the API: ", err.message] }), _jsx(Text, { children: JSON.stringify(err.response?.data, undefined, 2) })] }), withHTTPMessages === "full" ? _jsx(HttpMessages, { err: err }) : undefined, withStack && "stack" in err ? _jsx(ErrorStack, { err: err }) : undefined] }));
40
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(ErrorBox, { children: [_jsx(ErrorText, { bold: true, underline: true, children: "API CLIENT ERROR" }), _jsxs(ErrorText, { children: ["An error occurred while communicating with the API: ", err.message] }), _jsx(ErrorDetails, { err: err }), _jsx(Text, { children: JSON.stringify(err.response?.data, undefined, 2) })] }), withHTTPMessages === "full" ? _jsx(HttpMessages, { err: err }) : undefined, withStack && "stack" in err ? _jsx(ErrorStack, { err: err }) : undefined] }));
29
41
  }
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box } from "ink";
3
3
  import ErrorStack from "./ErrorStack.js";
4
4
  import ErrorText from "./ErrorText.js";
@@ -9,5 +9,5 @@ const issueURL = "https://github.com/mittwald/cli/issues/new";
9
9
  * have a specific rendering function.
10
10
  */
11
11
  export default function GenericError({ err, withStack, withIssue = true, title = "Error", }) {
12
- return (_jsxs(_Fragment, { children: [_jsxs(ErrorBox, { children: [_jsx(ErrorText, { bold: true, underline: true, children: title.toUpperCase() }), _jsx(ErrorText, { children: "An error occurred while executing this command:" }), _jsx(Box, { marginX: 2, children: _jsx(ErrorText, { children: err.toString() }) }), withIssue ? (_jsxs(ErrorText, { children: ["If you believe this to be a bug, please open an issue at ", issueURL, "."] })) : undefined] }), withStack && "stack" in err ? _jsx(ErrorStack, { err: err }) : undefined] }));
12
+ return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(ErrorBox, { children: [_jsx(ErrorText, { bold: true, underline: true, children: title.toUpperCase() }), _jsx(ErrorText, { children: "An error occurred while executing this command:" }), _jsx(Box, { marginX: 2, children: _jsx(ErrorText, { children: err.toString() }) }), withIssue ? (_jsxs(ErrorText, { children: ["If you believe this to be a bug, please open an issue at ", issueURL, "."] })) : undefined] }), withStack && "stack" in err ? _jsx(ErrorStack, { err: err }) : undefined] }));
13
13
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { FailedFlagValidationError, RequiredArgsError, } from "@oclif/core/lib/parser/errors.js";
3
- import { ApiClientError } from "@mittwald/api-client-commons";
3
+ import { AxiosError } from "@mittwald/api-client-commons";
4
4
  import InteractiveInputRequiredError from "../../../lib/error/InteractiveInputRequiredError.js";
5
5
  import UnexpectedShortIDPassedError from "../../../lib/error/UnexpectedShortIDPassedError.js";
6
6
  import GenericError from "./Error/GenericError.js";
@@ -21,7 +21,7 @@ export const ErrorBox = ({ err }) => {
21
21
  else if (err instanceof RequiredArgsError) {
22
22
  return _jsx(InvalidArgsError, { err: err });
23
23
  }
24
- else if (err instanceof ApiClientError) {
24
+ else if (err instanceof AxiosError) {
25
25
  return _jsx(APIError, { err: err, withStack: true, withHTTPMessages: "body" });
26
26
  }
27
27
  else if (err instanceof InteractiveInputRequiredError) {
@@ -1,5 +1,6 @@
1
1
  import React, { PropsWithChildren } from "react";
2
2
  export type ValueProps = PropsWithChildren<{
3
3
  notSet?: boolean;
4
+ bold?: boolean;
4
5
  }>;
5
6
  export declare const Value: React.FC<ValueProps>;
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Text } from "ink";
3
- export const Value = ({ children, notSet }) => {
3
+ export const Value = ({ children, notSet, bold }) => {
4
4
  if (notSet || children === undefined) {
5
5
  return _jsx(Text, { color: "gray", children: "not set" });
6
6
  }
7
- return _jsx(Text, { color: "blue", children: children });
7
+ return (_jsx(Text, { color: "blue", bold: bold, children: children }));
8
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mittwald/cli",
3
- "version": "1.0.0-alpha.44",
3
+ "version": "1.0.0-alpha.45",
4
4
  "description": "Hand-crafted CLI for the mittwald API",
5
5
  "license": "MIT",
6
6
  "author": {