vercel-api-js 0.1.6 → 0.1.8
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/.turbo/turbo-build.log +3 -9
- package/CHANGELOG.md +12 -0
- package/dist/index.cjs +27 -7
- package/dist/index.d.ts +10 -3
- package/dist/index.mjs +27 -7
- package/package.json +4 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
|
|
2
|
-
> vercel-api-js@0.1.
|
|
2
|
+
> vercel-api-js@0.1.8 build /home/runner/work/openapi-clients/openapi-clients/packages/vercel-api-js
|
|
3
3
|
> rimraf dist && rollup -c
|
|
4
4
|
|
|
5
5
|
[36m
|
|
6
6
|
[1m./src/index.ts[22m → [1mdist/index.cjs, dist/index.mjs[22m...[39m
|
|
7
|
-
[
|
|
8
|
-
[1mopenapi-codegen.config.ts: (106:67)[22m
|
|
9
|
-
[90m
|
|
10
|
-
[7m106[0m const updatedOpenAPIDocument = JSON.stringify(openAPIDocument, (key, value) => {
|
|
11
|
-
[7m [0m [91m ~~~[0m
|
|
12
|
-
[39m
|
|
13
|
-
[32mcreated [1mdist/index.cjs, dist/index.mjs[22m in [1m4.3s[22m[39m
|
|
7
|
+
[32mcreated [1mdist/index.cjs, dist/index.mjs[22m in [1m6.3s[22m[39m
|
|
14
8
|
[36m
|
|
15
9
|
[1m./src/index.ts[22m → [1mdist/index.d.ts[22m...[39m
|
|
16
|
-
[32mcreated [1mdist/index.d.ts[22m in [
|
|
10
|
+
[32mcreated [1mdist/index.d.ts[22m in [1m5.9s[22m[39m
|
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -28,14 +28,21 @@ function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
|
28
28
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
function notEmpty(value) {
|
|
32
|
+
return value !== null && value !== undefined;
|
|
33
|
+
}
|
|
34
|
+
function compactObject(obj) {
|
|
35
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
const baseUrl = 'https://api.vercel.com';
|
|
32
39
|
async function fetch$1({ url, method, body, headers, pathParams, queryParams, signal, token, fetchImpl }) {
|
|
33
40
|
try {
|
|
34
|
-
const requestHeaders = {
|
|
41
|
+
const requestHeaders = compactObject({
|
|
35
42
|
'Content-Type': 'application/json',
|
|
36
|
-
Authorization: `Bearer ${token}
|
|
43
|
+
Authorization: token ? `Bearer ${token}` : undefined,
|
|
37
44
|
...headers
|
|
38
|
-
};
|
|
45
|
+
});
|
|
39
46
|
/**
|
|
40
47
|
* As the fetch API is being used, when multipart/form-data is specified
|
|
41
48
|
* the Content-Type header must be deleted so that the browser can set
|
|
@@ -45,10 +52,15 @@ async function fetch$1({ url, method, body, headers, pathParams, queryParams, si
|
|
|
45
52
|
if (requestHeaders['Content-Type']?.toLowerCase().includes('multipart/form-data')) {
|
|
46
53
|
delete requestHeaders['Content-Type'];
|
|
47
54
|
}
|
|
55
|
+
const payload = body instanceof FormData
|
|
56
|
+
? body
|
|
57
|
+
: requestHeaders['Content-Type'] === 'application/json'
|
|
58
|
+
? JSON.stringify(body)
|
|
59
|
+
: body;
|
|
48
60
|
const response = await fetchImpl(`${baseUrl}${resolveUrl(url, queryParams, pathParams)}`, {
|
|
49
61
|
signal,
|
|
50
62
|
method: method.toUpperCase(),
|
|
51
|
-
body:
|
|
63
|
+
body: payload,
|
|
52
64
|
headers: requestHeaders
|
|
53
65
|
});
|
|
54
66
|
if (!response.ok) {
|
|
@@ -934,8 +946,6 @@ class VercelApi {
|
|
|
934
946
|
_VercelApi_token.set(this, void 0);
|
|
935
947
|
_VercelApi_fetch.set(this, void 0);
|
|
936
948
|
__classPrivateFieldSet(this, _VercelApi_token, options.token, "f");
|
|
937
|
-
if (!options.token)
|
|
938
|
-
throw new Error('Token is required');
|
|
939
949
|
__classPrivateFieldSet(this, _VercelApi_fetch, options.fetch || fetch, "f");
|
|
940
950
|
if (!__classPrivateFieldGet(this, _VercelApi_fetch, "f"))
|
|
941
951
|
throw new Error('Fetch is required');
|
|
@@ -965,11 +975,21 @@ class VercelApi {
|
|
|
965
975
|
get auth() {
|
|
966
976
|
return {
|
|
967
977
|
accessToken: async ({ code, redirectUri, clientId, clientSecret }) => {
|
|
968
|
-
|
|
978
|
+
const result = await fetch$1({
|
|
969
979
|
method: 'POST',
|
|
980
|
+
url: `/v2/oauth/access_token`,
|
|
981
|
+
token: null,
|
|
982
|
+
fetchImpl: __classPrivateFieldGet(this, _VercelApi_fetch, "f"),
|
|
970
983
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
971
984
|
body: formEncoded({ code, redirect_uri: redirectUri, client_id: clientId, client_secret: clientSecret })
|
|
972
985
|
});
|
|
986
|
+
return {
|
|
987
|
+
accessToken: result.access_token,
|
|
988
|
+
tokenType: result.token_type,
|
|
989
|
+
installationId: result.installation_id,
|
|
990
|
+
userId: result.user_id,
|
|
991
|
+
teamId: result.team_id
|
|
992
|
+
};
|
|
973
993
|
}
|
|
974
994
|
};
|
|
975
995
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -930,7 +930,7 @@ type Response = {
|
|
|
930
930
|
type FetchImpl = (url: string, init?: RequestInit | undefined) => Promise<Response>;
|
|
931
931
|
|
|
932
932
|
type FetcherExtraProps = {
|
|
933
|
-
token: string;
|
|
933
|
+
token: string | null;
|
|
934
934
|
fetchImpl: FetchImpl;
|
|
935
935
|
};
|
|
936
936
|
type ErrorWrapper<TError> = TError | {
|
|
@@ -15272,7 +15272,7 @@ type RequiredKeys<T> = {
|
|
|
15272
15272
|
}[keyof T];
|
|
15273
15273
|
|
|
15274
15274
|
interface VercelApiOptions {
|
|
15275
|
-
token: string;
|
|
15275
|
+
token: string | null;
|
|
15276
15276
|
fetch?: FetchImpl;
|
|
15277
15277
|
}
|
|
15278
15278
|
type ApiProxy = {
|
|
@@ -15286,7 +15286,7 @@ declare class VercelApi {
|
|
|
15286
15286
|
constructor(options: VercelApiOptions);
|
|
15287
15287
|
get api(): ApiProxy;
|
|
15288
15288
|
get auth(): {
|
|
15289
|
-
accessToken: ({ code, redirectUri, clientId, clientSecret }: AccessTokenOptions) => Promise<
|
|
15289
|
+
accessToken: ({ code, redirectUri, clientId, clientSecret }: AccessTokenOptions) => Promise<AccessTokenResult>;
|
|
15290
15290
|
};
|
|
15291
15291
|
request<Endpoint extends keyof typeof operationsByPath>(endpoint: Endpoint, params: RequestEndpointParams<Endpoint>): Promise<ReturnType<{
|
|
15292
15292
|
'POST /v8/artifacts/events': (variables: RecordEventsVariables, signal?: AbortSignal | undefined) => Promise<undefined>;
|
|
@@ -16027,5 +16027,12 @@ type AccessTokenOptions = {
|
|
|
16027
16027
|
clientId: string;
|
|
16028
16028
|
clientSecret: string;
|
|
16029
16029
|
};
|
|
16030
|
+
type AccessTokenResult = {
|
|
16031
|
+
accessToken: string;
|
|
16032
|
+
tokenType: string;
|
|
16033
|
+
installationId: string;
|
|
16034
|
+
userId: string;
|
|
16035
|
+
teamId: string | null;
|
|
16036
|
+
};
|
|
16030
16037
|
|
|
16031
16038
|
export { components as Components, schemas as Schemas, VercelApi, VercelApiOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -26,14 +26,21 @@ function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
|
26
26
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
function notEmpty(value) {
|
|
30
|
+
return value !== null && value !== undefined;
|
|
31
|
+
}
|
|
32
|
+
function compactObject(obj) {
|
|
33
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => notEmpty(value)));
|
|
34
|
+
}
|
|
35
|
+
|
|
29
36
|
const baseUrl = 'https://api.vercel.com';
|
|
30
37
|
async function fetch$1({ url, method, body, headers, pathParams, queryParams, signal, token, fetchImpl }) {
|
|
31
38
|
try {
|
|
32
|
-
const requestHeaders = {
|
|
39
|
+
const requestHeaders = compactObject({
|
|
33
40
|
'Content-Type': 'application/json',
|
|
34
|
-
Authorization: `Bearer ${token}
|
|
41
|
+
Authorization: token ? `Bearer ${token}` : undefined,
|
|
35
42
|
...headers
|
|
36
|
-
};
|
|
43
|
+
});
|
|
37
44
|
/**
|
|
38
45
|
* As the fetch API is being used, when multipart/form-data is specified
|
|
39
46
|
* the Content-Type header must be deleted so that the browser can set
|
|
@@ -43,10 +50,15 @@ async function fetch$1({ url, method, body, headers, pathParams, queryParams, si
|
|
|
43
50
|
if (requestHeaders['Content-Type']?.toLowerCase().includes('multipart/form-data')) {
|
|
44
51
|
delete requestHeaders['Content-Type'];
|
|
45
52
|
}
|
|
53
|
+
const payload = body instanceof FormData
|
|
54
|
+
? body
|
|
55
|
+
: requestHeaders['Content-Type'] === 'application/json'
|
|
56
|
+
? JSON.stringify(body)
|
|
57
|
+
: body;
|
|
46
58
|
const response = await fetchImpl(`${baseUrl}${resolveUrl(url, queryParams, pathParams)}`, {
|
|
47
59
|
signal,
|
|
48
60
|
method: method.toUpperCase(),
|
|
49
|
-
body:
|
|
61
|
+
body: payload,
|
|
50
62
|
headers: requestHeaders
|
|
51
63
|
});
|
|
52
64
|
if (!response.ok) {
|
|
@@ -932,8 +944,6 @@ class VercelApi {
|
|
|
932
944
|
_VercelApi_token.set(this, void 0);
|
|
933
945
|
_VercelApi_fetch.set(this, void 0);
|
|
934
946
|
__classPrivateFieldSet(this, _VercelApi_token, options.token, "f");
|
|
935
|
-
if (!options.token)
|
|
936
|
-
throw new Error('Token is required');
|
|
937
947
|
__classPrivateFieldSet(this, _VercelApi_fetch, options.fetch || fetch, "f");
|
|
938
948
|
if (!__classPrivateFieldGet(this, _VercelApi_fetch, "f"))
|
|
939
949
|
throw new Error('Fetch is required');
|
|
@@ -963,11 +973,21 @@ class VercelApi {
|
|
|
963
973
|
get auth() {
|
|
964
974
|
return {
|
|
965
975
|
accessToken: async ({ code, redirectUri, clientId, clientSecret }) => {
|
|
966
|
-
|
|
976
|
+
const result = await fetch$1({
|
|
967
977
|
method: 'POST',
|
|
978
|
+
url: `/v2/oauth/access_token`,
|
|
979
|
+
token: null,
|
|
980
|
+
fetchImpl: __classPrivateFieldGet(this, _VercelApi_fetch, "f"),
|
|
968
981
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
969
982
|
body: formEncoded({ code, redirect_uri: redirectUri, client_id: clientId, client_secret: clientSecret })
|
|
970
983
|
});
|
|
984
|
+
return {
|
|
985
|
+
accessToken: result.access_token,
|
|
986
|
+
tokenType: result.token_type,
|
|
987
|
+
installationId: result.installation_id,
|
|
988
|
+
userId: result.user_id,
|
|
989
|
+
teamId: result.team_id
|
|
990
|
+
};
|
|
971
991
|
}
|
|
972
992
|
};
|
|
973
993
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vercel-api-js",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "Vercel API client for Node.js",
|
|
5
5
|
"author": "SferaDev",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"bugs": {
|
|
8
|
-
"url": "https://github.com/SferaDev/
|
|
8
|
+
"url": "https://github.com/SferaDev/openapi-clients/issues"
|
|
9
9
|
},
|
|
10
|
-
"homepage": "https://github.com/SferaDev/
|
|
10
|
+
"homepage": "https://github.com/SferaDev/openapi-clients#readme",
|
|
11
11
|
"main": "dist/index.cjs",
|
|
12
12
|
"module": "dist/index.mjs",
|
|
13
13
|
"typings": "dist/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/SferaDev/
|
|
20
|
+
"url": "git+https://github.com/SferaDev/openapi-clients.git"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"tsc": "tsc --noEmit",
|