vercel-api-js 0.25.2 → 1.0.0
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/client.d.mts +228 -0
- package/dist/client.d.ts +228 -0
- package/dist/client.js +75 -0
- package/dist/client.mjs +68 -0
- package/dist/generated/components.d.mts +2600 -0
- package/dist/generated/components.d.ts +2600 -0
- package/dist/generated/components.js +3309 -0
- package/dist/generated/components.mjs +3125 -0
- package/dist/generated/schemas.d.mts +6536 -0
- package/dist/generated/schemas.d.ts +6536 -0
- package/dist/generated/schemas.js +7107 -0
- package/dist/generated/schemas.mjs +7077 -0
- package/dist/generated/types.d.mts +15000 -0
- package/dist/generated/types.d.ts +15000 -0
- package/dist/generated/types.js +950 -0
- package/dist/generated/types.mjs +945 -0
- package/dist/index.d.mts +1711 -30825
- package/dist/index.d.ts +1711 -30825
- package/dist/index.js +49 -0
- package/dist/index.mjs +7 -845
- package/dist/utils/fetch.d.mts +18 -0
- package/dist/utils/fetch.d.ts +18 -0
- package/dist/utils/fetch.js +8 -0
- package/dist/utils/fetch.mjs +5 -0
- package/dist/utils/fetcher.d.mts +22 -0
- package/dist/utils/fetcher.d.ts +22 -0
- package/dist/utils/fetcher.js +68 -0
- package/dist/utils/fetcher.mjs +65 -0
- package/dist/utils/lang.d.mts +1 -0
- package/dist/utils/lang.d.ts +1 -0
- package/dist/utils/lang.js +9 -0
- package/dist/utils/lang.mjs +6 -0
- package/dist/utils/types.d.mts +3 -0
- package/dist/utils/types.d.ts +3 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.mjs +1 -0
- package/package.json +29 -19
- package/.turbo/turbo-build.log +0 -14
- package/CHANGELOG.md +0 -756
- package/dist/index.cjs +0 -847
- package/dist/index.d.cts +0 -30832
- package/tsconfig.json +0 -19
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type RequestInit = {
|
|
2
|
+
body?: string | FormData | undefined;
|
|
3
|
+
headers?: Record<string, string> | undefined;
|
|
4
|
+
method?: string | undefined;
|
|
5
|
+
signal?: any | undefined;
|
|
6
|
+
};
|
|
7
|
+
export type Response = {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
status: number;
|
|
10
|
+
url: string;
|
|
11
|
+
json(): Promise<any>;
|
|
12
|
+
text(): Promise<string>;
|
|
13
|
+
headers?: {
|
|
14
|
+
get(name: string): string | null;
|
|
15
|
+
} | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type FetchImpl = (url: string, init?: RequestInit) => Promise<Response>;
|
|
18
|
+
export declare function formEncoded<T extends Record<string, string>>(data: T): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type RequestInit = {
|
|
2
|
+
body?: string | FormData | undefined;
|
|
3
|
+
headers?: Record<string, string> | undefined;
|
|
4
|
+
method?: string | undefined;
|
|
5
|
+
signal?: any | undefined;
|
|
6
|
+
};
|
|
7
|
+
export type Response = {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
status: number;
|
|
10
|
+
url: string;
|
|
11
|
+
json(): Promise<any>;
|
|
12
|
+
text(): Promise<string>;
|
|
13
|
+
headers?: {
|
|
14
|
+
get(name: string): string | null;
|
|
15
|
+
} | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type FetchImpl = (url: string, init?: RequestInit) => Promise<Response>;
|
|
18
|
+
export declare function formEncoded<T extends Record<string, string>>(data: T): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formEncoded = formEncoded;
|
|
4
|
+
function formEncoded(data) {
|
|
5
|
+
return Object.entries(data)
|
|
6
|
+
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
|
|
7
|
+
.join('&');
|
|
8
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FetchImpl } from "./fetch.mjs";
|
|
2
|
+
export type FetcherConfig = {
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
token?: string | null;
|
|
5
|
+
fetchImpl?: FetchImpl;
|
|
6
|
+
headers?: Record<string, any>;
|
|
7
|
+
};
|
|
8
|
+
export type ErrorWrapper<TError> = TError | {
|
|
9
|
+
status: 'unknown';
|
|
10
|
+
payload: string;
|
|
11
|
+
};
|
|
12
|
+
export type FetcherOptions<TBody, THeaders, TQueryParams, TPathParams> = {
|
|
13
|
+
url: string;
|
|
14
|
+
method: string;
|
|
15
|
+
body?: TBody | undefined;
|
|
16
|
+
headers?: THeaders | undefined;
|
|
17
|
+
queryParams?: TQueryParams | undefined;
|
|
18
|
+
pathParams?: TPathParams | undefined;
|
|
19
|
+
signal?: AbortSignal | undefined;
|
|
20
|
+
} & FetcherConfig;
|
|
21
|
+
export declare function client<TData, TError, TBody, THeaders, TQueryParams, TPathParams>({ url, method, body, headers, queryParams, signal, token, baseUrl, fetchImpl }: FetcherOptions<TBody, THeaders, TQueryParams, TPathParams>): Promise<TData>;
|
|
22
|
+
export default client;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FetchImpl } from "./fetch.js";
|
|
2
|
+
export type FetcherConfig = {
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
token?: string | null;
|
|
5
|
+
fetchImpl?: FetchImpl;
|
|
6
|
+
headers?: Record<string, any>;
|
|
7
|
+
};
|
|
8
|
+
export type ErrorWrapper<TError> = TError | {
|
|
9
|
+
status: 'unknown';
|
|
10
|
+
payload: string;
|
|
11
|
+
};
|
|
12
|
+
export type FetcherOptions<TBody, THeaders, TQueryParams, TPathParams> = {
|
|
13
|
+
url: string;
|
|
14
|
+
method: string;
|
|
15
|
+
body?: TBody | undefined;
|
|
16
|
+
headers?: THeaders | undefined;
|
|
17
|
+
queryParams?: TQueryParams | undefined;
|
|
18
|
+
pathParams?: TPathParams | undefined;
|
|
19
|
+
signal?: AbortSignal | undefined;
|
|
20
|
+
} & FetcherConfig;
|
|
21
|
+
export declare function client<TData, TError, TBody, THeaders, TQueryParams, TPathParams>({ url, method, body, headers, queryParams, signal, token, baseUrl, fetchImpl }: FetcherOptions<TBody, THeaders, TQueryParams, TPathParams>): Promise<TData>;
|
|
22
|
+
export default client;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.client = client;
|
|
4
|
+
const lang_1 = require("./lang.js");
|
|
5
|
+
async function client({ url, method, body, headers, queryParams, signal, token = null, baseUrl = '', fetchImpl = fetch }) {
|
|
6
|
+
try {
|
|
7
|
+
const requestHeaders = (0, lang_1.compactObject)({
|
|
8
|
+
'Content-Type': 'application/json',
|
|
9
|
+
Authorization: token ? `Bearer ${token}` : undefined,
|
|
10
|
+
...headers
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* As the fetch API is being used, when multipart/form-data is specified
|
|
14
|
+
* the Content-Type header must be deleted so that the browser can set
|
|
15
|
+
* the correct boundary.
|
|
16
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects#sending_files_using_a_formdata_object
|
|
17
|
+
*/
|
|
18
|
+
if (requestHeaders['Content-Type']?.toLowerCase().includes('multipart/form-data')) {
|
|
19
|
+
delete requestHeaders['Content-Type'];
|
|
20
|
+
}
|
|
21
|
+
const payload = body instanceof FormData
|
|
22
|
+
? body
|
|
23
|
+
: requestHeaders['Content-Type'] === 'application/json'
|
|
24
|
+
? JSON.stringify(body)
|
|
25
|
+
: body;
|
|
26
|
+
const fullUrl = `${baseUrl}${resolveUrl(url, queryParams)}`;
|
|
27
|
+
const response = await fetchImpl(fullUrl, {
|
|
28
|
+
signal,
|
|
29
|
+
method: method.toUpperCase(),
|
|
30
|
+
body: payload,
|
|
31
|
+
headers: requestHeaders
|
|
32
|
+
});
|
|
33
|
+
if (!response.ok) {
|
|
34
|
+
let error;
|
|
35
|
+
try {
|
|
36
|
+
error = await response.json();
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
error = {
|
|
40
|
+
status: 'unknown',
|
|
41
|
+
payload: e instanceof Error ? `Unexpected error (${e.message})` : 'Unexpected error'
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
if (response.headers?.get('content-type')?.includes('json')) {
|
|
47
|
+
return await response.json();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
// if it is not a json response, assume it is a blob and cast it to TData
|
|
51
|
+
return (await response.text());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
const errorObject = {
|
|
56
|
+
name: 'unknown',
|
|
57
|
+
message: e?.message ? `${e?.message}` : 'Network error'
|
|
58
|
+
};
|
|
59
|
+
throw errorObject;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const resolveUrl = (url, queryParams = {}) => {
|
|
63
|
+
let query = new URLSearchParams(queryParams).toString();
|
|
64
|
+
if (query)
|
|
65
|
+
query = `?${query}`;
|
|
66
|
+
return url + query;
|
|
67
|
+
};
|
|
68
|
+
exports.default = client;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { compactObject } from "./lang.mjs";
|
|
2
|
+
export async function client({ url, method, body, headers, queryParams, signal, token = null, baseUrl = '', fetchImpl = fetch }) {
|
|
3
|
+
try {
|
|
4
|
+
const requestHeaders = compactObject({
|
|
5
|
+
'Content-Type': 'application/json',
|
|
6
|
+
Authorization: token ? `Bearer ${token}` : undefined,
|
|
7
|
+
...headers
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* As the fetch API is being used, when multipart/form-data is specified
|
|
11
|
+
* the Content-Type header must be deleted so that the browser can set
|
|
12
|
+
* the correct boundary.
|
|
13
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects#sending_files_using_a_formdata_object
|
|
14
|
+
*/
|
|
15
|
+
if (requestHeaders['Content-Type']?.toLowerCase().includes('multipart/form-data')) {
|
|
16
|
+
delete requestHeaders['Content-Type'];
|
|
17
|
+
}
|
|
18
|
+
const payload = body instanceof FormData
|
|
19
|
+
? body
|
|
20
|
+
: requestHeaders['Content-Type'] === 'application/json'
|
|
21
|
+
? JSON.stringify(body)
|
|
22
|
+
: body;
|
|
23
|
+
const fullUrl = `${baseUrl}${resolveUrl(url, queryParams)}`;
|
|
24
|
+
const response = await fetchImpl(fullUrl, {
|
|
25
|
+
signal,
|
|
26
|
+
method: method.toUpperCase(),
|
|
27
|
+
body: payload,
|
|
28
|
+
headers: requestHeaders
|
|
29
|
+
});
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
let error;
|
|
32
|
+
try {
|
|
33
|
+
error = await response.json();
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
error = {
|
|
37
|
+
status: 'unknown',
|
|
38
|
+
payload: e instanceof Error ? `Unexpected error (${e.message})` : 'Unexpected error'
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
if (response.headers?.get('content-type')?.includes('json')) {
|
|
44
|
+
return await response.json();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// if it is not a json response, assume it is a blob and cast it to TData
|
|
48
|
+
return (await response.text());
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
const errorObject = {
|
|
53
|
+
name: 'unknown',
|
|
54
|
+
message: e?.message ? `${e?.message}` : 'Network error'
|
|
55
|
+
};
|
|
56
|
+
throw errorObject;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const resolveUrl = (url, queryParams = {}) => {
|
|
60
|
+
let query = new URLSearchParams(queryParams).toString();
|
|
61
|
+
if (query)
|
|
62
|
+
query = `?${query}`;
|
|
63
|
+
return url + query;
|
|
64
|
+
};
|
|
65
|
+
export default client;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function compactObject<T>(obj: Record<string, T | null | undefined>): Record<string, T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function compactObject<T>(obj: Record<string, T | null | undefined>): Record<string, T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compactObject = compactObject;
|
|
4
|
+
function notEmpty(value) {
|
|
5
|
+
return value !== null && value !== undefined;
|
|
6
|
+
}
|
|
7
|
+
function compactObject(obj) {
|
|
8
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vercel-api-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Vercel auto-generated type-safe API client",
|
|
5
5
|
"author": "SferaDev",
|
|
6
6
|
"license": "ISC",
|
|
@@ -8,29 +8,39 @@
|
|
|
8
8
|
"url": "https://github.com/SferaDev/openapi-clients/issues"
|
|
9
9
|
},
|
|
10
10
|
"homepage": "https://github.com/SferaDev/openapi-clients#readme",
|
|
11
|
-
"
|
|
12
|
-
"module": "dist/index.mjs",
|
|
13
|
-
"typings": "dist/index.d.ts",
|
|
14
|
-
"exports": {
|
|
15
|
-
"./package.json": "./package.json",
|
|
16
|
-
".": {
|
|
17
|
-
"import": {
|
|
18
|
-
"types": "./dist/index.d.mts",
|
|
19
|
-
"default": "./dist/index.mjs"
|
|
20
|
-
},
|
|
21
|
-
"require": {
|
|
22
|
-
"types": "./dist/index.d.cts",
|
|
23
|
-
"default": "./dist/index.cjs"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
},
|
|
11
|
+
"zshy": "./src/index.ts",
|
|
27
12
|
"repository": {
|
|
28
13
|
"type": "git",
|
|
29
14
|
"url": "git+https://github.com/SferaDev/openapi-clients.git"
|
|
30
15
|
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@kubb/cli": "^3.16.0",
|
|
18
|
+
"@kubb/core": "^3.16.0",
|
|
19
|
+
"@modelcontextprotocol/sdk": "^1.15.1",
|
|
20
|
+
"openapi-utils": "0.0.1"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@modelcontextprotocol/sdk": "^1.15.1"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"zod": "^4.0.5"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"module": "./dist/index.mjs",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.mjs",
|
|
38
|
+
"require": "./dist/index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
31
41
|
"scripts": {
|
|
32
42
|
"tsc": "tsc --noEmit",
|
|
33
|
-
"build": "
|
|
34
|
-
"generate": "
|
|
43
|
+
"build": "zshy",
|
|
44
|
+
"generate": "rimraf ./src/generated && kubb generate"
|
|
35
45
|
}
|
|
36
46
|
}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> vercel-api-js@0.25.2 build /home/runner/work/openapi-clients/openapi-clients/packages/vercel-api-js
|
|
3
|
-
> unbuild
|
|
4
|
-
|
|
5
|
-
[info] Automatically detected entries: src/index [esm] [cjs] [dts]
|
|
6
|
-
[info] Building vercel-api-js
|
|
7
|
-
[info] Cleaning dist directory: `./dist`
|
|
8
|
-
[success] Build succeeded for vercel-api-js
|
|
9
|
-
[log] dist/index.cjs (total size: 32.6 kB, chunk size: 32.6 kB, exports: VercelApi)
|
|
10
|
-
|
|
11
|
-
[log] dist/index.mjs (total size: 32.6 kB, chunk size: 32.6 kB, exports: VercelApi)
|
|
12
|
-
|
|
13
|
-
Σ Total dist size (byte size): 3.67 MB
|
|
14
|
-
[log]
|