@kubb/plugin-client 4.27.1 → 4.27.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios.cjs","names":[],"sources":["../../src/clients/axios.ts"],"sourcesContent":["import type { AxiosError,
|
|
1
|
+
{"version":3,"file":"axios.cjs","names":[],"sources":["../../src/clients/axios.ts"],"sourcesContent":["import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'\nimport axios from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n validateStatus?: (status: number) => boolean\n headers?: AxiosRequestConfig['headers']\n paramsSerializer?: AxiosRequestConfig['paramsSerializer']\n}\n\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers: AxiosResponse['headers']\n}\n\nexport type ResponseErrorConfig<TError = unknown> = AxiosError<TError>\n\nexport type Client = <TResponseData, _TError = unknown, TRequestData = unknown>(config: RequestConfig<TRequestData>) => Promise<ResponseConfig<TResponseData>>\n\nlet _config: Partial<RequestConfig> = {\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? JSON.parse(AXIOS_HEADERS) : undefined,\n}\n\nexport const getConfig = () => _config\n\nexport const setConfig = (config: RequestConfig) => {\n _config = config\n return getConfig()\n}\n\nexport const mergeConfig = <T extends RequestConfig>(...configs: Array<Partial<T>>): Partial<T> => {\n return configs.reduce<Partial<T>>((merged, config) => {\n return {\n ...merged,\n ...config,\n headers: {\n ...merged.headers,\n ...config.headers,\n },\n }\n }, {})\n}\n\nexport const axiosInstance = axios.create(getConfig())\n\nexport const client = async <TResponseData, TError = unknown, TRequestData = unknown>(\n config: RequestConfig<TRequestData>,\n): Promise<ResponseConfig<TResponseData>> => {\n return axiosInstance.request<TResponseData, ResponseConfig<TResponseData>>(mergeConfig(getConfig(), config)).catch((e: AxiosError<TError>) => {\n throw e\n })\n}\n\nclient.getConfig = getConfig\nclient.setConfig = setConfig\n\nexport default client\n"],"mappings":";;;;;;AAoCA,IAAI,UAAkC;CACpC,SAAS,OAAO,eAAe,cAAc,aAAa;CAC1D,SAAS,OAAO,kBAAkB,cAAc,KAAK,MAAM,cAAc,GAAG;CAC7E;AAED,MAAa,kBAAkB;AAE/B,MAAa,aAAa,WAA0B;AAClD,WAAU;AACV,QAAO,WAAW;;AAGpB,MAAa,eAAwC,GAAG,YAA2C;AACjG,QAAO,QAAQ,QAAoB,QAAQ,WAAW;AACpD,SAAO;GACL,GAAG;GACH,GAAG;GACH,SAAS;IACP,GAAG,OAAO;IACV,GAAG,OAAO;IACX;GACF;IACA,EAAE,CAAC;;AAGR,MAAa,gBAAgB,cAAM,OAAO,WAAW,CAAC;AAEtD,MAAa,SAAS,OACpB,WAC2C;AAC3C,QAAO,cAAc,QAAsD,YAAY,WAAW,EAAE,OAAO,CAAC,CAAC,OAAO,MAA0B;AAC5I,QAAM;GACN;;AAGJ,OAAO,YAAY;AACnB,OAAO,YAAY;AAEnB,oBAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios.js","names":[],"sources":["../../src/clients/axios.ts"],"sourcesContent":["import type { AxiosError,
|
|
1
|
+
{"version":3,"file":"axios.js","names":[],"sources":["../../src/clients/axios.ts"],"sourcesContent":["import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'\nimport axios from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n validateStatus?: (status: number) => boolean\n headers?: AxiosRequestConfig['headers']\n paramsSerializer?: AxiosRequestConfig['paramsSerializer']\n}\n\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers: AxiosResponse['headers']\n}\n\nexport type ResponseErrorConfig<TError = unknown> = AxiosError<TError>\n\nexport type Client = <TResponseData, _TError = unknown, TRequestData = unknown>(config: RequestConfig<TRequestData>) => Promise<ResponseConfig<TResponseData>>\n\nlet _config: Partial<RequestConfig> = {\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? JSON.parse(AXIOS_HEADERS) : undefined,\n}\n\nexport const getConfig = () => _config\n\nexport const setConfig = (config: RequestConfig) => {\n _config = config\n return getConfig()\n}\n\nexport const mergeConfig = <T extends RequestConfig>(...configs: Array<Partial<T>>): Partial<T> => {\n return configs.reduce<Partial<T>>((merged, config) => {\n return {\n ...merged,\n ...config,\n headers: {\n ...merged.headers,\n ...config.headers,\n },\n }\n }, {})\n}\n\nexport const axiosInstance = axios.create(getConfig())\n\nexport const client = async <TResponseData, TError = unknown, TRequestData = unknown>(\n config: RequestConfig<TRequestData>,\n): Promise<ResponseConfig<TResponseData>> => {\n return axiosInstance.request<TResponseData, ResponseConfig<TResponseData>>(mergeConfig(getConfig(), config)).catch((e: AxiosError<TError>) => {\n throw e\n })\n}\n\nclient.getConfig = getConfig\nclient.setConfig = setConfig\n\nexport default client\n"],"mappings":";;;;AAoCA,IAAI,UAAkC;CACpC,SAAS,OAAO,eAAe,cAAc,aAAa;CAC1D,SAAS,OAAO,kBAAkB,cAAc,KAAK,MAAM,cAAc,GAAG;CAC7E;AAED,MAAa,kBAAkB;AAE/B,MAAa,aAAa,WAA0B;AAClD,WAAU;AACV,QAAO,WAAW;;AAGpB,MAAa,eAAwC,GAAG,YAA2C;AACjG,QAAO,QAAQ,QAAoB,QAAQ,WAAW;AACpD,SAAO;GACL,GAAG;GACH,GAAG;GACH,SAAS;IACP,GAAG,OAAO;IACV,GAAG,OAAO;IACX;GACF;IACA,EAAE,CAAC;;AAGR,MAAa,gBAAgB,MAAM,OAAO,WAAW,CAAC;AAEtD,MAAa,SAAS,OACpB,WAC2C;AAC3C,QAAO,cAAc,QAAsD,YAAY,WAAW,EAAE,OAAO,CAAC,CAAC,OAAO,MAA0B;AAC5I,QAAM;GACN;;AAGJ,OAAO,YAAY;AACnB,OAAO,YAAY;AAEnB,oBAAe"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-client",
|
|
3
|
-
"version": "4.27.
|
|
3
|
+
"version": "4.27.3",
|
|
4
4
|
"description": "API client generator plugin for Kubb, creating type-safe HTTP clients (Axios, Fetch) from OpenAPI specifications for making API requests.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-client",
|
|
@@ -90,11 +90,11 @@
|
|
|
90
90
|
],
|
|
91
91
|
"dependencies": {
|
|
92
92
|
"@kubb/react-fabric": "0.12.11",
|
|
93
|
-
"@kubb/core": "4.27.
|
|
94
|
-
"@kubb/oas": "4.27.
|
|
95
|
-
"@kubb/plugin-oas": "4.27.
|
|
96
|
-
"@kubb/plugin-ts": "4.27.
|
|
97
|
-
"@kubb/plugin-zod": "4.27.
|
|
93
|
+
"@kubb/core": "4.27.3",
|
|
94
|
+
"@kubb/oas": "4.27.3",
|
|
95
|
+
"@kubb/plugin-oas": "4.27.3",
|
|
96
|
+
"@kubb/plugin-ts": "4.27.3",
|
|
97
|
+
"@kubb/plugin-zod": "4.27.3"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"axios": "^1.13.5"
|
package/src/clients/axios.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AxiosError,
|
|
1
|
+
import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'
|
|
2
2
|
import axios from 'axios'
|
|
3
3
|
|
|
4
4
|
declare const AXIOS_BASE: string
|
|
@@ -36,7 +36,7 @@ export type Client = <TResponseData, _TError = unknown, TRequestData = unknown>(
|
|
|
36
36
|
|
|
37
37
|
let _config: Partial<RequestConfig> = {
|
|
38
38
|
baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,
|
|
39
|
-
headers: typeof AXIOS_HEADERS !== 'undefined' ?
|
|
39
|
+
headers: typeof AXIOS_HEADERS !== 'undefined' ? JSON.parse(AXIOS_HEADERS) : undefined,
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export const getConfig = () => _config
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AxiosError,
|
|
1
|
+
import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'
|
|
2
2
|
import axios from 'axios'
|
|
3
3
|
|
|
4
4
|
declare const AXIOS_BASE: string
|
|
@@ -35,7 +35,7 @@ export type Client = <TData, _TError = unknown, TVariables = unknown>(config: Re
|
|
|
35
35
|
|
|
36
36
|
let _config: Partial<RequestConfig> = {
|
|
37
37
|
baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,
|
|
38
|
-
headers: typeof AXIOS_HEADERS !== 'undefined' ?
|
|
38
|
+
headers: typeof AXIOS_HEADERS !== 'undefined' ? JSON.parse(AXIOS_HEADERS) : undefined,
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export const getConfig = () => _config
|