diff --git a/.fernignore b/.fernignore index 22164fd..b5902dd 100644 --- a/.fernignore +++ b/.fernignore @@ -6,3 +6,5 @@ src/core/fetcher/Fetcher.ts tests/integration src/wrapper src/index.ts +src/api/resources/auth/client/Client.ts +src/core/fetcher/getRequestBody.ts diff --git a/src/api/resources/auth/client/Client.ts b/src/api/resources/auth/client/Client.ts index eabaa07..ddb01df 100644 --- a/src/api/resources/auth/client/Client.ts +++ b/src/api/resources/auth/client/Client.ts @@ -2,12 +2,12 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as environments from "../../../../environments"; -import * as core from "../../../../core"; -import * as Vectara from "../../../index"; -import * as serializers from "../../../../serialization/index"; import urlJoin from "url-join"; +import * as core from "../../../../core"; +import * as environments from "../../../../environments"; import * as errors from "../../../../errors/index"; +import * as serializers from "../../../../serialization/index"; +import * as Vectara from "../../../index"; export declare namespace Auth { interface Options { @@ -55,7 +55,7 @@ export class Auth { url: urlJoin( ((await core.Supplier.get(this._options.environment)) ?? environments.VectaraEnvironment.Production) .auth, - "oauth/token" + "oauth2/token" ), method: "POST", headers: { @@ -72,12 +72,16 @@ export class Auth { "X-Fern-Runtime-Version": core.RUNTIME.version, ...requestOptions?.headers, }, - contentType: "application/json", - requestType: "json", + contentType: "application/x-www-form-urlencoded", + requestType: "urlencoded", body: { ...serializers.AuthGetTokenRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), grant_type: "client_credentials", }, + // queryParameters: { + // ...serializers.AuthGetTokenRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + // grant_type: "client_credentials", + // }, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, diff --git a/src/core/fetcher/Fetcher.ts b/src/core/fetcher/Fetcher.ts index 5ced493..cce7cde 100644 --- a/src/core/fetcher/Fetcher.ts +++ b/src/core/fetcher/Fetcher.ts @@ -66,7 +66,7 @@ export async function fetcherImpl(args: Fetcher.Args): Promise { if (type.includes("json")) { return JSON.stringify(body); + } else if (type === "urlencoded") { + const params = new URLSearchParams(); + if (typeof body === "object" && body !== null) { + Object.entries(body).forEach(([key, value]) => { + params.append(key, String(value)); + }); + } + return params.toString(); } else { return body as BodyInit; } diff --git a/src/wrapper/client.ts b/src/wrapper/client.ts index c4944f3..3e2fe84 100644 --- a/src/wrapper/client.ts +++ b/src/wrapper/client.ts @@ -1,12 +1,12 @@ - import { VectaraClient as FernClient } from "../client"; - import * as core from "../core"; import { - ChatFullResponse, + ChatFullResponse, ChatParameters, ChatStreamedResponse, GenerationParameters, SearchCorporaParameters } from "../api"; +import { VectaraClient as FernClient } from "../Client"; +import * as core from "../core"; import RequestOptions = FernClient.RequestOptions;