@deliverart/sdk-js-core 0.1.1 → 0.1.2
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 +6 -0
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/package.json +1 -1
- package/src/ApiClient.ts +5 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -94,6 +94,9 @@ var AbstractApiRequest = class {
|
|
|
94
94
|
}
|
|
95
95
|
return result.data;
|
|
96
96
|
}
|
|
97
|
+
parseResponse(data) {
|
|
98
|
+
return this.validateOutput(data);
|
|
99
|
+
}
|
|
97
100
|
};
|
|
98
101
|
function createApiClient(config) {
|
|
99
102
|
const http = import_axios.default.create({ baseURL: config.baseUrl });
|
|
@@ -114,7 +117,7 @@ function createApiClient(config) {
|
|
|
114
117
|
params: query,
|
|
115
118
|
data: request.method !== "GET" ? input : void 0
|
|
116
119
|
});
|
|
117
|
-
return request.
|
|
120
|
+
return request.parseResponse(res.data);
|
|
118
121
|
},
|
|
119
122
|
addPlugin(plugin) {
|
|
120
123
|
const extension = plugin.setup(this);
|
package/dist/index.d.cts
CHANGED
|
@@ -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): Output;
|
|
31
32
|
}
|
|
32
33
|
interface ApiClientBase {
|
|
33
34
|
http: AxiosInstance;
|
package/dist/index.d.ts
CHANGED
|
@@ -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): Output;
|
|
31
32
|
}
|
|
32
33
|
interface ApiClientBase {
|
|
33
34
|
http: AxiosInstance;
|
package/dist/index.js
CHANGED
|
@@ -55,6 +55,9 @@ var AbstractApiRequest = class {
|
|
|
55
55
|
}
|
|
56
56
|
return result.data;
|
|
57
57
|
}
|
|
58
|
+
parseResponse(data) {
|
|
59
|
+
return this.validateOutput(data);
|
|
60
|
+
}
|
|
58
61
|
};
|
|
59
62
|
function createApiClient(config) {
|
|
60
63
|
const http = axios.create({ baseURL: config.baseUrl });
|
|
@@ -75,7 +78,7 @@ function createApiClient(config) {
|
|
|
75
78
|
params: query,
|
|
76
79
|
data: request.method !== "GET" ? input : void 0
|
|
77
80
|
});
|
|
78
|
-
return request.
|
|
81
|
+
return request.parseResponse(res.data);
|
|
79
82
|
},
|
|
80
83
|
addPlugin(plugin) {
|
|
81
84
|
const extension = plugin.setup(this);
|
package/package.json
CHANGED
package/src/ApiClient.ts
CHANGED
|
@@ -63,6 +63,10 @@ export abstract class AbstractApiRequest<Input, Output, Query = unknown, Headers
|
|
|
63
63
|
}
|
|
64
64
|
return result.data
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
parseResponse(data: unknown): Output {
|
|
68
|
+
return this.validateOutput(data)
|
|
69
|
+
}
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
interface ApiClientBase {
|
|
@@ -98,7 +102,7 @@ export function createApiClient<Extensions extends ApiExtension = NonNullable<un
|
|
|
98
102
|
data: request.method !== 'GET' ? input : undefined,
|
|
99
103
|
})
|
|
100
104
|
|
|
101
|
-
return request.
|
|
105
|
+
return request.parseResponse(res.data)
|
|
102
106
|
},
|
|
103
107
|
|
|
104
108
|
addPlugin<T extends ApiExtension>(plugin: ApiClientPlugin<T>) {
|