@sebspark/openapi-client 1.4.5 → 1.5.1
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.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +21 -1
- package/dist/index.mjs +21 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseClient, ClientOptions } from '@sebspark/openapi-core';
|
|
2
|
+
import { Logger } from 'winston';
|
|
2
3
|
export * from '@sebspark/retry';
|
|
3
4
|
|
|
4
|
-
declare const TypedClient: <C extends Partial<BaseClient>>(baseURL: string, globalOptions?: ClientOptions) => C;
|
|
5
|
+
declare const TypedClient: <C extends Partial<BaseClient>>(baseURL: string, globalOptions?: ClientOptions, logger?: Logger) => C;
|
|
5
6
|
|
|
6
7
|
export { TypedClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseClient, ClientOptions } from '@sebspark/openapi-core';
|
|
2
|
+
import { Logger } from 'winston';
|
|
2
3
|
export * from '@sebspark/retry';
|
|
3
4
|
|
|
4
|
-
declare const TypedClient: <C extends Partial<BaseClient>>(baseURL: string, globalOptions?: ClientOptions) => C;
|
|
5
|
+
declare const TypedClient: <C extends Partial<BaseClient>>(baseURL: string, globalOptions?: ClientOptions, logger?: Logger) => C;
|
|
5
6
|
|
|
6
7
|
export { TypedClient };
|
package/dist/index.js
CHANGED
|
@@ -91,7 +91,27 @@ var paramsSerializer = (format) => (params) => {
|
|
|
91
91
|
};
|
|
92
92
|
|
|
93
93
|
// src/client.ts
|
|
94
|
-
var TypedClient = (baseURL, globalOptions) => {
|
|
94
|
+
var TypedClient = (baseURL, globalOptions, logger) => {
|
|
95
|
+
if (logger) {
|
|
96
|
+
import_axios.default.interceptors.request.use((request) => {
|
|
97
|
+
const requestObject = {
|
|
98
|
+
url: request.url,
|
|
99
|
+
params: request.params,
|
|
100
|
+
headers: request.headers
|
|
101
|
+
};
|
|
102
|
+
logger.debug(JSON.stringify(requestObject, null, 2));
|
|
103
|
+
return request;
|
|
104
|
+
});
|
|
105
|
+
import_axios.default.interceptors.response.use((response) => {
|
|
106
|
+
const responseObject = {
|
|
107
|
+
data: response.data,
|
|
108
|
+
config: response.config,
|
|
109
|
+
headers: response.headers
|
|
110
|
+
};
|
|
111
|
+
logger.debug(JSON.stringify(responseObject, null, 2));
|
|
112
|
+
return response;
|
|
113
|
+
});
|
|
114
|
+
}
|
|
95
115
|
const client = {
|
|
96
116
|
get: (url, args, opts) => callServer(mergeArgs(baseURL, url, "get", args, opts, globalOptions)),
|
|
97
117
|
post: (url, args, opts) => callServer(mergeArgs(baseURL, url, "post", args, opts, globalOptions)),
|
package/dist/index.mjs
CHANGED
|
@@ -56,7 +56,27 @@ var paramsSerializer = (format) => (params) => {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
// src/client.ts
|
|
59
|
-
var TypedClient = (baseURL, globalOptions) => {
|
|
59
|
+
var TypedClient = (baseURL, globalOptions, logger) => {
|
|
60
|
+
if (logger) {
|
|
61
|
+
axios.interceptors.request.use((request) => {
|
|
62
|
+
const requestObject = {
|
|
63
|
+
url: request.url,
|
|
64
|
+
params: request.params,
|
|
65
|
+
headers: request.headers
|
|
66
|
+
};
|
|
67
|
+
logger.debug(JSON.stringify(requestObject, null, 2));
|
|
68
|
+
return request;
|
|
69
|
+
});
|
|
70
|
+
axios.interceptors.response.use((response) => {
|
|
71
|
+
const responseObject = {
|
|
72
|
+
data: response.data,
|
|
73
|
+
config: response.config,
|
|
74
|
+
headers: response.headers
|
|
75
|
+
};
|
|
76
|
+
logger.debug(JSON.stringify(responseObject, null, 2));
|
|
77
|
+
return response;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
60
80
|
const client = {
|
|
61
81
|
get: (url, args, opts) => callServer(mergeArgs(baseURL, url, "get", args, opts, globalOptions)),
|
|
62
82
|
post: (url, args, opts) => callServer(mergeArgs(baseURL, url, "post", args, opts, globalOptions)),
|