@autometa/http 1.4.13 → 1.4.15

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.
@@ -26,7 +26,7 @@ describe(MetaConfigBuilder.name, () => {
26
26
  expect(config.schemas.toObject()).toEqual({
27
27
  200: parser,
28
28
  201: parser,
29
- 202: parser
29
+ 202: parser,
30
30
  });
31
31
  });
32
32
  });
@@ -4,7 +4,7 @@ import {
4
4
  RequestHook,
5
5
  ResponseHook,
6
6
  SchemaParser,
7
- StatusCode
7
+ StatusCode,
8
8
  } from "./types";
9
9
 
10
10
  export interface SchemaConfig {
package/src/schema.map.ts CHANGED
@@ -37,7 +37,7 @@ export class SchemaMap {
37
37
  if ("parse" in parser) {
38
38
  return parser.parse(data);
39
39
  }
40
- if('validate' in parser) {
40
+ if ("validate" in parser) {
41
41
  return parser.validate(data);
42
42
  }
43
43
  try {
@@ -31,13 +31,13 @@ export function transformResponse(
31
31
  if (allowPlainText) {
32
32
  return data;
33
33
  }
34
-
35
- const response = highlight(data, { language: "html" });
34
+ const dataStr = typeof data === "string" ? data : JSON.stringify(data);
35
+ const response = highlight(dataStr, { language: "html" });
36
36
  const message = [
37
37
  `Could not parse a response as json, and this request was not configured to allow plain text responses.`,
38
38
  `To allow plain text responses, use the 'allowPlainText' method on the HTTP client.`,
39
39
  "",
40
- response
40
+ response,
41
41
  ];
42
42
  throw new AutomationError(message.join("\n"));
43
43
  }
package/tsup.config.ts CHANGED
@@ -4,7 +4,7 @@ export default defineConfig({
4
4
  clean: true, // clean up the dist folder
5
5
  format: ["cjs", "esm"], // generate cjs and esm files
6
6
  dts: true,
7
- sourcemap:true, // generate sourcemaps
7
+ sourcemap: true, // generate sourcemaps
8
8
  skipNodeModulesBundle: true,
9
9
  entryPoints: ["src/index.ts"],
10
10
  target: "es2020",