Skip to content

Commit 61077ae

Browse files
fix: remove kubb plugin-client from runtime deps (#356)
1 parent 85e4ac0 commit 61077ae

211 files changed

Lines changed: 8459 additions & 3666 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

kubb.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default defineConfig({
3333
path: "./client/api",
3434
},
3535
client: "axios",
36+
bundle: true,
3637
}),
3738
pluginZod({
3839
output: {

package-lock.json

Lines changed: 161 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
"commit": "commit"
5454
},
5555
"dependencies": {
56-
"@kubb/plugin-client": "^4.38.0",
5756
"@modelcontextprotocol/sdk": "^1.29.0",
5857
"@sentry/node": "^10.58.0",
5958
"axios": "^1.18.0",
@@ -65,6 +64,7 @@
6564
"@commitlint/prompt-cli": "^21.0.2",
6665
"@kubb/cli": "^4.38.0",
6766
"@kubb/core": "^4.38.0",
67+
"@kubb/plugin-client": "^4.38.0",
6868
"@kubb/plugin-faker": "^4.38.0",
6969
"@kubb/plugin-oas": "^4.38.0",
7070
"@kubb/plugin-ts": "^4.38.0",

src/generated/.kubb/config.ts

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,46 @@
11
export function buildFormData<T = unknown>(data: T): FormData {
2-
const formData = new FormData()
2+
const formData = new FormData();
33

44
function appendData(key: string, value: any) {
55
if (value instanceof Blob) {
6-
formData.append(key, value)
7-
return
6+
formData.append(key, value);
7+
return;
88
}
99
if (value instanceof Date) {
10-
formData.append(key, value.toISOString())
11-
return
10+
formData.append(key, value.toISOString());
11+
return;
1212
}
13-
if (typeof value === 'number' || typeof value === 'boolean') {
14-
formData.append(key, String(value))
15-
return
13+
if (typeof value === "number" || typeof value === "boolean") {
14+
formData.append(key, String(value));
15+
return;
1616
}
17-
if (typeof value === 'string') {
18-
formData.append(key, value)
19-
return
17+
if (typeof value === "string") {
18+
formData.append(key, value);
19+
return;
2020
}
21-
if (typeof value === 'object') {
22-
formData.append(key, new Blob([JSON.stringify(value)], { type: 'application/json' }))
23-
return
21+
if (typeof value === "object") {
22+
formData.append(
23+
key,
24+
new Blob([JSON.stringify(value)], { type: "application/json" }),
25+
);
26+
return;
2427
}
2528
}
2629

2730
if (data) {
2831
Object.entries(data).forEach(([key, value]) => {
29-
if (value === undefined || value === null) return
32+
if (value === undefined || value === null) return;
3033

3134
if (Array.isArray(value)) {
3235
for (const valueItem of value) {
33-
if (valueItem === undefined || valueItem === null) continue
34-
appendData(key, valueItem)
36+
if (valueItem === undefined || valueItem === null) continue;
37+
appendData(key, valueItem);
3538
}
3639
} else {
37-
appendData(key, value)
40+
appendData(key, value);
3841
}
39-
})
42+
});
4043
}
4144

42-
return formData
43-
}
45+
return formData;
46+
}

src/generated/.kubb/fetch.ts

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import type { AxiosError, AxiosRequestConfig, AxiosResponse } from "axios";
2+
import axios from "axios";
3+
4+
declare const AXIOS_BASE: string;
5+
declare const AXIOS_HEADERS: string;
6+
7+
/**
8+
* Subset of AxiosRequestConfig
9+
*/
10+
export type RequestConfig<TData = unknown> = {
11+
baseURL?: string;
12+
url?: string;
13+
method?: "GET" | "PUT" | "PATCH" | "POST" | "DELETE" | "OPTIONS" | "HEAD";
14+
params?: unknown;
15+
data?: TData | FormData;
16+
responseType?:
17+
| "arraybuffer"
18+
| "blob"
19+
| "document"
20+
| "json"
21+
| "text"
22+
| "stream";
23+
signal?: AbortSignal;
24+
validateStatus?: (status: number) => boolean;
25+
headers?: AxiosRequestConfig["headers"];
26+
};
27+
28+
/**
29+
* Subset of AxiosResponse
30+
*/
31+
export type ResponseConfig<TData = unknown> = {
32+
data: TData;
33+
status: number;
34+
statusText: string;
35+
headers: AxiosResponse["headers"];
36+
};
37+
38+
export type ResponseErrorConfig<TError = unknown> = AxiosError<TError>;
39+
40+
export type Client = <TData, _TError = unknown, TVariables = unknown>(
41+
config: RequestConfig<TVariables>,
42+
) => Promise<ResponseConfig<TData>>;
43+
44+
let _config: Partial<RequestConfig> = {
45+
baseURL: typeof AXIOS_BASE !== "undefined" ? AXIOS_BASE : undefined,
46+
headers:
47+
typeof AXIOS_HEADERS !== "undefined"
48+
? JSON.parse(AXIOS_HEADERS)
49+
: undefined,
50+
};
51+
52+
export const getConfig = () => _config;
53+
54+
export const setConfig = (config: RequestConfig) => {
55+
_config = config;
56+
return getConfig();
57+
};
58+
59+
export const mergeConfig = <T extends RequestConfig>(
60+
...configs: Array<Partial<T>>
61+
): Partial<T> => {
62+
return configs.reduce<Partial<T>>((merged, config) => {
63+
return {
64+
...merged,
65+
...config,
66+
headers: {
67+
...merged.headers,
68+
...config.headers,
69+
},
70+
};
71+
}, {});
72+
};
73+
74+
export const axiosInstance = axios.create(getConfig());
75+
76+
export const fetch = async <TData, TError = unknown, TVariables = unknown>(
77+
config: RequestConfig<TVariables>,
78+
): Promise<ResponseConfig<TData>> => {
79+
return axiosInstance
80+
.request<TData, ResponseConfig<TData>>(mergeConfig(getConfig(), config))
81+
.catch((e: AxiosError<TError>) => {
82+
throw e;
83+
});
84+
};
85+
86+
fetch.getConfig = getConfig;
87+
fetch.setConfig = setConfig;
Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,48 @@
11
/**
2-
* Generated by Kubb (https://kubb.dev/).
3-
* Do not edit manually.
4-
*/
2+
* Generated by Kubb (https://kubb.dev/).
3+
* Do not edit manually.
4+
*/
55

6-
import fetch from "@kubb/plugin-client/clients/axios";
7-
import type { GetV1BodyMeasurementsQueryResponse, GetV1BodyMeasurementsQueryParams, GetV1BodyMeasurementsHeaderParams, GetV1BodyMeasurements400, GetV1BodyMeasurements404 } from "../types/GetV1BodyMeasurements.ts";
8-
import type { Client, RequestConfig, ResponseErrorConfig } from "@kubb/plugin-client/clients/axios";
6+
import type {
7+
Client,
8+
RequestConfig,
9+
ResponseErrorConfig,
10+
} from "../../.kubb/fetch.ts";
11+
import type {
12+
GetV1BodyMeasurementsQueryResponse,
13+
GetV1BodyMeasurementsQueryParams,
14+
GetV1BodyMeasurementsHeaderParams,
15+
GetV1BodyMeasurements400,
16+
GetV1BodyMeasurements404,
17+
} from "../types/GetV1BodyMeasurements.ts";
18+
import { fetch } from "../../.kubb/fetch.ts";
919

1020
function getGetV1BodyMeasurementsUrl() {
11-
const res = { method: 'GET', url: `/v1/body_measurements` as const }
12-
return res
21+
const res = { method: "GET", url: `/v1/body_measurements` as const };
22+
return res;
1323
}
1424

1525
/**
1626
* @summary Get a paginated list of body measurements for the authenticated user
1727
* {@link /v1/body_measurements}
1828
*/
19-
export async function getV1BodyMeasurements(headers: GetV1BodyMeasurementsHeaderParams, params?: GetV1BodyMeasurementsQueryParams, config: Partial<RequestConfig> & { client?: Client } = {}) {
20-
const { client: request = fetch, ...requestConfig } = config
21-
29+
export async function getV1BodyMeasurements(
30+
headers: GetV1BodyMeasurementsHeaderParams,
31+
params?: GetV1BodyMeasurementsQueryParams,
32+
config: Partial<RequestConfig> & { client?: Client } = {},
33+
) {
34+
const { client: request = fetch, ...requestConfig } = config;
2235

23-
24-
const res = await request<GetV1BodyMeasurementsQueryResponse, ResponseErrorConfig<GetV1BodyMeasurements400 | GetV1BodyMeasurements404>, unknown>({ method : "GET", url : getGetV1BodyMeasurementsUrl().url.toString(), params, ... requestConfig, headers : { ...headers, ...requestConfig.headers } })
25-
return res.data
26-
}
36+
const res = await request<
37+
GetV1BodyMeasurementsQueryResponse,
38+
ResponseErrorConfig<GetV1BodyMeasurements400 | GetV1BodyMeasurements404>,
39+
unknown
40+
>({
41+
method: "GET",
42+
url: getGetV1BodyMeasurementsUrl().url.toString(),
43+
params,
44+
...requestConfig,
45+
headers: { ...headers, ...requestConfig.headers },
46+
});
47+
return res.data;
48+
}
Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,48 @@
11
/**
2-
* Generated by Kubb (https://kubb.dev/).
3-
* Do not edit manually.
4-
*/
2+
* Generated by Kubb (https://kubb.dev/).
3+
* Do not edit manually.
4+
*/
55

6-
import fetch from "@kubb/plugin-client/clients/axios";
7-
import type { GetV1BodyMeasurementsDateQueryResponse, GetV1BodyMeasurementsDatePathParams, GetV1BodyMeasurementsDateHeaderParams, GetV1BodyMeasurementsDate404 } from "../types/GetV1BodyMeasurementsDate.ts";
8-
import type { Client, RequestConfig, ResponseErrorConfig } from "@kubb/plugin-client/clients/axios";
6+
import type {
7+
Client,
8+
RequestConfig,
9+
ResponseErrorConfig,
10+
} from "../../.kubb/fetch.ts";
11+
import type {
12+
GetV1BodyMeasurementsDateQueryResponse,
13+
GetV1BodyMeasurementsDatePathParams,
14+
GetV1BodyMeasurementsDateHeaderParams,
15+
GetV1BodyMeasurementsDate404,
16+
} from "../types/GetV1BodyMeasurementsDate.ts";
17+
import { fetch } from "../../.kubb/fetch.ts";
918

10-
function getGetV1BodyMeasurementsDateUrl(date: GetV1BodyMeasurementsDatePathParams["date"]) {
11-
const res = { method: 'GET', url: `/v1/body_measurements/${date}` as const }
12-
return res
19+
function getGetV1BodyMeasurementsDateUrl(
20+
date: GetV1BodyMeasurementsDatePathParams["date"],
21+
) {
22+
const res = { method: "GET", url: `/v1/body_measurements/${date}` as const };
23+
return res;
1324
}
1425

1526
/**
1627
* @summary Get a single body measurement by date
1728
* {@link /v1/body_measurements/:date}
1829
*/
19-
export async function getV1BodyMeasurementsDate(date: GetV1BodyMeasurementsDatePathParams["date"], headers: GetV1BodyMeasurementsDateHeaderParams, config: Partial<RequestConfig> & { client?: Client } = {}) {
20-
const { client: request = fetch, ...requestConfig } = config
21-
30+
export async function getV1BodyMeasurementsDate(
31+
date: GetV1BodyMeasurementsDatePathParams["date"],
32+
headers: GetV1BodyMeasurementsDateHeaderParams,
33+
config: Partial<RequestConfig> & { client?: Client } = {},
34+
) {
35+
const { client: request = fetch, ...requestConfig } = config;
2236

23-
24-
const res = await request<GetV1BodyMeasurementsDateQueryResponse, ResponseErrorConfig<GetV1BodyMeasurementsDate404>, unknown>({ method : "GET", url : getGetV1BodyMeasurementsDateUrl(date).url.toString(), ... requestConfig, headers : { ...headers, ...requestConfig.headers } })
25-
return res.data
26-
}
37+
const res = await request<
38+
GetV1BodyMeasurementsDateQueryResponse,
39+
ResponseErrorConfig<GetV1BodyMeasurementsDate404>,
40+
unknown
41+
>({
42+
method: "GET",
43+
url: getGetV1BodyMeasurementsDateUrl(date).url.toString(),
44+
...requestConfig,
45+
headers: { ...headers, ...requestConfig.headers },
46+
});
47+
return res.data;
48+
}
Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,56 @@
11
/**
2-
* Generated by Kubb (https://kubb.dev/).
3-
* Do not edit manually.
4-
*/
2+
* Generated by Kubb (https://kubb.dev/).
3+
* Do not edit manually.
4+
*/
55

6-
import fetch from "@kubb/plugin-client/clients/axios";
7-
import type { GetV1ExerciseHistoryExercisetemplateidQueryResponse, GetV1ExerciseHistoryExercisetemplateidPathParams, GetV1ExerciseHistoryExercisetemplateidQueryParams, GetV1ExerciseHistoryExercisetemplateidHeaderParams, GetV1ExerciseHistoryExercisetemplateid400 } from "../types/GetV1ExerciseHistoryExercisetemplateid.ts";
8-
import type { Client, RequestConfig, ResponseErrorConfig } from "@kubb/plugin-client/clients/axios";
6+
import type {
7+
Client,
8+
RequestConfig,
9+
ResponseErrorConfig,
10+
} from "../../.kubb/fetch.ts";
11+
import type {
12+
GetV1ExerciseHistoryExercisetemplateidQueryResponse,
13+
GetV1ExerciseHistoryExercisetemplateidPathParams,
14+
GetV1ExerciseHistoryExercisetemplateidQueryParams,
15+
GetV1ExerciseHistoryExercisetemplateidHeaderParams,
16+
GetV1ExerciseHistoryExercisetemplateid400,
17+
} from "../types/GetV1ExerciseHistoryExercisetemplateid.ts";
18+
import { fetch } from "../../.kubb/fetch.ts";
919

10-
function getGetV1ExerciseHistoryExercisetemplateidUrl(exerciseTemplateId: GetV1ExerciseHistoryExercisetemplateidPathParams["exerciseTemplateId"]) {
11-
const res = { method: 'GET', url: `/v1/exercise_history/${exerciseTemplateId}` as const }
12-
return res
20+
function getGetV1ExerciseHistoryExercisetemplateidUrl(
21+
exerciseTemplateId: GetV1ExerciseHistoryExercisetemplateidPathParams["exerciseTemplateId"],
22+
) {
23+
const res = {
24+
method: "GET",
25+
url: `/v1/exercise_history/${exerciseTemplateId}` as const,
26+
};
27+
return res;
1328
}
1429

1530
/**
1631
* @summary Get exercise history for a specific exercise template
1732
* {@link /v1/exercise_history/:exerciseTemplateId}
1833
*/
19-
export async function getV1ExerciseHistoryExercisetemplateid(exerciseTemplateId: GetV1ExerciseHistoryExercisetemplateidPathParams["exerciseTemplateId"], headers: GetV1ExerciseHistoryExercisetemplateidHeaderParams, params?: GetV1ExerciseHistoryExercisetemplateidQueryParams, config: Partial<RequestConfig> & { client?: Client } = {}) {
20-
const { client: request = fetch, ...requestConfig } = config
21-
34+
export async function getV1ExerciseHistoryExercisetemplateid(
35+
exerciseTemplateId: GetV1ExerciseHistoryExercisetemplateidPathParams["exerciseTemplateId"],
36+
headers: GetV1ExerciseHistoryExercisetemplateidHeaderParams,
37+
params?: GetV1ExerciseHistoryExercisetemplateidQueryParams,
38+
config: Partial<RequestConfig> & { client?: Client } = {},
39+
) {
40+
const { client: request = fetch, ...requestConfig } = config;
2241

23-
24-
const res = await request<GetV1ExerciseHistoryExercisetemplateidQueryResponse, ResponseErrorConfig<GetV1ExerciseHistoryExercisetemplateid400>, unknown>({ method : "GET", url : getGetV1ExerciseHistoryExercisetemplateidUrl(exerciseTemplateId).url.toString(), params, ... requestConfig, headers : { ...headers, ...requestConfig.headers } })
25-
return res.data
26-
}
42+
const res = await request<
43+
GetV1ExerciseHistoryExercisetemplateidQueryResponse,
44+
ResponseErrorConfig<GetV1ExerciseHistoryExercisetemplateid400>,
45+
unknown
46+
>({
47+
method: "GET",
48+
url: getGetV1ExerciseHistoryExercisetemplateidUrl(
49+
exerciseTemplateId,
50+
).url.toString(),
51+
params,
52+
...requestConfig,
53+
headers: { ...headers, ...requestConfig.headers },
54+
});
55+
return res.data;
56+
}

0 commit comments

Comments
 (0)