vercel-api-js 0.1.5 → 0.1.6

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,5 +1,5 @@
1
1
 
2
- > vercel-api-js@0.1.5 build /home/runner/work/openapi-clients/openapi-clients/packages/vercel-api-js
2
+ > vercel-api-js@0.1.6 build /home/runner/work/openapi-clients/openapi-clients/packages/vercel-api-js
3
3
  > rimraf dist && rollup -c
4
4
 
5
5
  
@@ -10,7 +10,7 @@
10
10
  106 const updatedOpenAPIDocument = JSON.stringify(openAPIDocument, (key, value) => {
11
11
     ~~~
12
12
  
13
- created dist/index.cjs, dist/index.mjs in 4.4s
13
+ created dist/index.cjs, dist/index.mjs in 4.3s
14
14
  
15
15
  ./src/index.ts → dist/index.d.ts...
16
- created dist/index.d.ts in 4s
16
+ created dist/index.d.ts in 4.7s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # vercel-api-js
2
2
 
3
+ ## 0.1.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 53e14fe: Add accessToken auth method
8
+
3
9
  ## 0.1.5
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -922,6 +922,12 @@ const operationsByTag = {
922
922
  }
923
923
  };
924
924
 
925
+ function formEncoded(data) {
926
+ return Object.entries(data)
927
+ .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
928
+ .join('&');
929
+ }
930
+
925
931
  var _VercelApi_token, _VercelApi_fetch;
926
932
  class VercelApi {
927
933
  constructor(options) {
@@ -948,14 +954,25 @@ class VercelApi {
948
954
  return undefined;
949
955
  }
950
956
  const method = operationsByTag[namespace][operation];
951
- return (params) => {
952
- return method({ ...params, token, fetchImpl });
957
+ return async (params) => {
958
+ return await method({ ...params, token, fetchImpl });
953
959
  };
954
960
  }
955
961
  });
956
962
  }
957
963
  });
958
964
  }
965
+ get auth() {
966
+ return {
967
+ accessToken: async ({ code, redirectUri, clientId, clientSecret }) => {
968
+ return await __classPrivateFieldGet(this, _VercelApi_fetch, "f").call(this, `${baseUrl}/v2/oauth/access_token`, {
969
+ method: 'POST',
970
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
971
+ body: formEncoded({ code, redirect_uri: redirectUri, client_id: clientId, client_secret: clientSecret })
972
+ });
973
+ }
974
+ };
975
+ }
959
976
  async request(endpoint, params) {
960
977
  const [method = '', url = ''] = endpoint.split(' ');
961
978
  const extraParams = (params || {});
package/dist/index.d.ts CHANGED
@@ -15285,6 +15285,9 @@ declare class VercelApi {
15285
15285
  #private;
15286
15286
  constructor(options: VercelApiOptions);
15287
15287
  get api(): ApiProxy;
15288
+ get auth(): {
15289
+ accessToken: ({ code, redirectUri, clientId, clientSecret }: AccessTokenOptions) => Promise<Response>;
15290
+ };
15288
15291
  request<Endpoint extends keyof typeof operationsByPath>(endpoint: Endpoint, params: RequestEndpointParams<Endpoint>): Promise<ReturnType<{
15289
15292
  'POST /v8/artifacts/events': (variables: RecordEventsVariables, signal?: AbortSignal | undefined) => Promise<undefined>;
15290
15293
  'GET /v8/artifacts/status': (variables: StatusVariables, signal?: AbortSignal | undefined) => Promise<StatusResponse>;
@@ -16018,5 +16021,11 @@ declare class VercelApi {
16018
16021
  'POST /v1/edge-config/{edgeConfigId}/token': (variables: CreateEdgeConfigTokenVariables, signal?: AbortSignal | undefined) => Promise<CreateEdgeConfigTokenResponse>;
16019
16022
  }[Endpoint]>>;
16020
16023
  }
16024
+ type AccessTokenOptions = {
16025
+ redirectUri: string;
16026
+ code: string;
16027
+ clientId: string;
16028
+ clientSecret: string;
16029
+ };
16021
16030
 
16022
16031
  export { components as Components, schemas as Schemas, VercelApi, VercelApiOptions };
package/dist/index.mjs CHANGED
@@ -920,6 +920,12 @@ const operationsByTag = {
920
920
  }
921
921
  };
922
922
 
923
+ function formEncoded(data) {
924
+ return Object.entries(data)
925
+ .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
926
+ .join('&');
927
+ }
928
+
923
929
  var _VercelApi_token, _VercelApi_fetch;
924
930
  class VercelApi {
925
931
  constructor(options) {
@@ -946,14 +952,25 @@ class VercelApi {
946
952
  return undefined;
947
953
  }
948
954
  const method = operationsByTag[namespace][operation];
949
- return (params) => {
950
- return method({ ...params, token, fetchImpl });
955
+ return async (params) => {
956
+ return await method({ ...params, token, fetchImpl });
951
957
  };
952
958
  }
953
959
  });
954
960
  }
955
961
  });
956
962
  }
963
+ get auth() {
964
+ return {
965
+ accessToken: async ({ code, redirectUri, clientId, clientSecret }) => {
966
+ return await __classPrivateFieldGet(this, _VercelApi_fetch, "f").call(this, `${baseUrl}/v2/oauth/access_token`, {
967
+ method: 'POST',
968
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
969
+ body: formEncoded({ code, redirect_uri: redirectUri, client_id: clientId, client_secret: clientSecret })
970
+ });
971
+ }
972
+ };
973
+ }
957
974
  async request(endpoint, params) {
958
975
  const [method = '', url = ''] = endpoint.split(' ');
959
976
  const extraParams = (params || {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vercel-api-js",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Vercel API client for Node.js",
5
5
  "author": "SferaDev",
6
6
  "license": "ISC",