@deliverart/sdk-js-core 0.1.1 → 0.1.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @deliverart/sdk-js-core
2
2
 
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - e177edc: Expose rawResponse
8
+
9
+ ## 0.1.2
10
+
11
+ ### Patch Changes
12
+
13
+ - b204aab: Add parseResponse method
14
+
3
15
  ## 0.1.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -94,6 +94,10 @@ var AbstractApiRequest = class {
94
94
  }
95
95
  return result.data;
96
96
  }
97
+ parseResponse(data, rawResponse) {
98
+ void rawResponse;
99
+ return this.validateOutput(data);
100
+ }
97
101
  };
98
102
  function createApiClient(config) {
99
103
  const http = import_axios.default.create({ baseURL: config.baseUrl });
@@ -114,7 +118,7 @@ function createApiClient(config) {
114
118
  params: query,
115
119
  data: request.method !== "GET" ? input : void 0
116
120
  });
117
- return request.validateOutput(res.data);
121
+ return request.parseResponse(res.data, res);
118
122
  },
119
123
  addPlugin(plugin) {
120
124
  const extension = plugin.setup(this);
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { AxiosInstance } from 'axios';
1
+ import { AxiosResponse, AxiosInstance } from 'axios';
2
2
  import { ZodSchema, ZodIssue } from 'zod';
3
3
 
4
4
  type ApiExtension = Record<string, unknown>;
@@ -28,6 +28,7 @@ declare abstract class AbstractApiRequest<Input, Output, Query = unknown, Header
28
28
  validateQuery(): Query | undefined;
29
29
  validateHeaders(): Headers | undefined;
30
30
  validateOutput(data: unknown): Output;
31
+ parseResponse(data: unknown, rawResponse?: AxiosResponse): Output;
31
32
  }
32
33
  interface ApiClientBase {
33
34
  http: AxiosInstance;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AxiosInstance } from 'axios';
1
+ import { AxiosResponse, AxiosInstance } from 'axios';
2
2
  import { ZodSchema, ZodIssue } from 'zod';
3
3
 
4
4
  type ApiExtension = Record<string, unknown>;
@@ -28,6 +28,7 @@ declare abstract class AbstractApiRequest<Input, Output, Query = unknown, Header
28
28
  validateQuery(): Query | undefined;
29
29
  validateHeaders(): Headers | undefined;
30
30
  validateOutput(data: unknown): Output;
31
+ parseResponse(data: unknown, rawResponse?: AxiosResponse): Output;
31
32
  }
32
33
  interface ApiClientBase {
33
34
  http: AxiosInstance;
package/dist/index.js CHANGED
@@ -55,6 +55,10 @@ var AbstractApiRequest = class {
55
55
  }
56
56
  return result.data;
57
57
  }
58
+ parseResponse(data, rawResponse) {
59
+ void rawResponse;
60
+ return this.validateOutput(data);
61
+ }
58
62
  };
59
63
  function createApiClient(config) {
60
64
  const http = axios.create({ baseURL: config.baseUrl });
@@ -75,7 +79,7 @@ function createApiClient(config) {
75
79
  params: query,
76
80
  data: request.method !== "GET" ? input : void 0
77
81
  });
78
- return request.validateOutput(res.data);
82
+ return request.parseResponse(res.data, res);
79
83
  },
80
84
  addPlugin(plugin) {
81
85
  const extension = plugin.setup(this);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deliverart/sdk-js-core",
3
3
  "description": "Core SDK for DeliverArt, providing essential functionalities and utilities.",
4
- "version": "0.1.1",
4
+ "version": "0.1.3",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
package/src/ApiClient.ts CHANGED
@@ -1,4 +1,4 @@
1
- import axios, { AxiosInstance } from 'axios'
1
+ import axios, { AxiosInstance, AxiosResponse } from 'axios'
2
2
  import { ZodSchema } from 'zod'
3
3
 
4
4
  import { InputValidationError, OutputValidationError } from './errors'
@@ -63,6 +63,11 @@ export abstract class AbstractApiRequest<Input, Output, Query = unknown, Headers
63
63
  }
64
64
  return result.data
65
65
  }
66
+
67
+ parseResponse(data: unknown, rawResponse?: AxiosResponse): Output {
68
+ void rawResponse
69
+ return this.validateOutput(data)
70
+ }
66
71
  }
67
72
 
68
73
  interface ApiClientBase {
@@ -98,7 +103,7 @@ export function createApiClient<Extensions extends ApiExtension = NonNullable<un
98
103
  data: request.method !== 'GET' ? input : undefined,
99
104
  })
100
105
 
101
- return request.validateOutput(res.data)
106
+ return request.parseResponse(res.data, res)
102
107
  },
103
108
 
104
109
  addPlugin<T extends ApiExtension>(plugin: ApiClientPlugin<T>) {