@rexeus/typeweaver-clients 0.4.0 → 0.4.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/dist/lib/ApiClient.ts +16 -14
- package/package.json +6 -6
package/dist/lib/ApiClient.ts
CHANGED
|
@@ -70,7 +70,6 @@ export abstract class ApiClient {
|
|
|
70
70
|
"Base URL must be provided either in axios instance or in constructor"
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
|
-
|
|
74
73
|
this.unknownResponseHandling = props.unknownResponseHandling ?? "throw";
|
|
75
74
|
this.isSuccessStatusCode =
|
|
76
75
|
props.isSuccessStatusCode ??
|
|
@@ -118,6 +117,7 @@ export abstract class ApiClient {
|
|
|
118
117
|
url,
|
|
119
118
|
data: body,
|
|
120
119
|
headers,
|
|
120
|
+
baseURL: this.baseUrl,
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
return this.createResponse(response);
|
|
@@ -169,7 +169,7 @@ export abstract class ApiClient {
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
return Object.entries(param).reduce((acc, [key, value]) => {
|
|
172
|
-
const result = acc.replace(`:${key}`, value);
|
|
172
|
+
const result = acc.replace(`:${key}`, encodeURIComponent(value));
|
|
173
173
|
|
|
174
174
|
if (result === acc) {
|
|
175
175
|
throw new Error(
|
|
@@ -181,33 +181,35 @@ export abstract class ApiClient {
|
|
|
181
181
|
}, path);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
private
|
|
184
|
+
private createUrl(path: string, query?: IHttpQuery): string {
|
|
185
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
186
|
+
const queryString = this.buildQueryString(query);
|
|
187
|
+
return queryString
|
|
188
|
+
? `${normalizedPath}?${queryString}`
|
|
189
|
+
: normalizedPath;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private buildQueryString(query?: IHttpQuery): string {
|
|
185
193
|
if (!query) {
|
|
186
|
-
return;
|
|
194
|
+
return "";
|
|
187
195
|
}
|
|
188
196
|
|
|
189
|
-
const
|
|
197
|
+
const params = new URLSearchParams();
|
|
190
198
|
for (const [key, value] of Object.entries(query)) {
|
|
191
199
|
if (value === undefined) {
|
|
192
200
|
continue;
|
|
193
201
|
}
|
|
194
202
|
if (!Array.isArray(value)) {
|
|
195
|
-
|
|
203
|
+
params.append(key, value);
|
|
196
204
|
continue;
|
|
197
205
|
}
|
|
198
|
-
|
|
199
206
|
for (const item of value) {
|
|
200
207
|
if (item !== undefined) {
|
|
201
|
-
|
|
208
|
+
params.append(key, item);
|
|
202
209
|
}
|
|
203
210
|
}
|
|
204
211
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
private createUrl(path: string, query?: IHttpQuery): string {
|
|
208
|
-
const url = new URL(path, this.baseUrl);
|
|
209
|
-
this.addQuery(url, query);
|
|
210
|
-
return url.toString();
|
|
212
|
+
return params.toString();
|
|
211
213
|
}
|
|
212
214
|
|
|
213
215
|
private createHeader(header: any): any {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rexeus/typeweaver-clients",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Generates HTTP clients directly from your API definitions. Powered by Typeweaver 🧵✨",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -49,20 +49,20 @@
|
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"axios": "^1.13.0",
|
|
51
51
|
"zod": "^4.3.0",
|
|
52
|
-
"@rexeus/typeweaver-core": "^0.4.
|
|
53
|
-
"@rexeus/typeweaver-gen": "^0.4.
|
|
52
|
+
"@rexeus/typeweaver-core": "^0.4.2",
|
|
53
|
+
"@rexeus/typeweaver-gen": "^0.4.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@hono/node-server": "^1.19.7",
|
|
57
57
|
"axios": "^1.13.2",
|
|
58
58
|
"test-utils": "file:../test-utils",
|
|
59
59
|
"zod": "^4.3.6",
|
|
60
|
-
"@rexeus/typeweaver-core": "^0.4.
|
|
61
|
-
"@rexeus/typeweaver-gen": "^0.4.
|
|
60
|
+
"@rexeus/typeweaver-core": "^0.4.2",
|
|
61
|
+
"@rexeus/typeweaver-gen": "^0.4.2"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"case": "^1.6.3",
|
|
65
|
-
"@rexeus/typeweaver-zod-to-ts": "^0.4.
|
|
65
|
+
"@rexeus/typeweaver-zod-to-ts": "^0.4.2"
|
|
66
66
|
},
|
|
67
67
|
"scripts": {
|
|
68
68
|
"typecheck": "tsc --noEmit",
|