From 1708f0e1c59400f7b4012d2c8b4ab7a8e204f58d Mon Sep 17 00:00:00 2001 From: Ewan Harris Date: Tue, 9 Apr 2024 14:38:38 +0100 Subject: [PATCH] fix: resolve circular import --- common.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/common.ts b/common.ts index a8b2587..2f054bd 100644 --- a/common.ts +++ b/common.ts @@ -14,7 +14,7 @@ import { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios"; import { Configuration } from "./configuration"; -import { Credentials } from "./credentials"; +import type { Credentials } from "./credentials"; import { FgaApiError, FgaApiInternalError, @@ -180,15 +180,13 @@ export async function attemptHttpRequest( /** * creates an axios request function */ -export const createRequestFunction = function (axiosArgs: RequestArgs, axiosInstance: AxiosInstance, configuration: Configuration, credentials?: Credentials) { +export const createRequestFunction = function (axiosArgs: RequestArgs, axiosInstance: AxiosInstance, configuration: Configuration, credentials: Credentials) { configuration.isValid(); const retryParams = axiosArgs.options?.retryParams ? axiosArgs.options?.retryParams : configuration.retryParams; const maxRetry:number = retryParams ? retryParams.maxRetry : 0; const minWaitInMs:number = retryParams ? retryParams.minWaitInMs : 0; - if (!credentials) { - credentials = Credentials.init(configuration); - } + return async (axios: AxiosInstance = axiosInstance) : PromiseResult => { await setBearerAuthToObject(axiosArgs.options.headers, credentials!);