diff --git a/src/environments.ts b/src/environments.ts deleted file mode 100644 index 4f34efa..0000000 --- a/src/environments.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -export const SquidexEnvironment = { - Default: "https://cloud.squidex.io", -} as const; - -export type SquidexEnvironment = typeof SquidexEnvironment.Default; diff --git a/src/wrapper/SquidexClient.ts b/src/wrapper/SquidexClient.ts index 7929bc6..74e31dd 100644 --- a/src/wrapper/SquidexClient.ts +++ b/src/wrapper/SquidexClient.ts @@ -1,4 +1,3 @@ -import * as environments from "../environments"; import { AppsApi, AppsApiInterface, @@ -69,12 +68,12 @@ export interface SquidexOptions { /** * Custom headers to be added to each request. */ - customHeader?: Record; + customHeaders?: Record; /** * The URL to your Squidex installation (cloud by default). */ - environment?: environments.SquidexEnvironment | string; + url?: string; /** * A custom fetcher for normal requests. @@ -240,8 +239,8 @@ export class SquidexClients { /** * The current URL to the Squidex installation. */ - public get environment() { - return this.clientOptions.environment || environments.SquidexEnvironment.Default; + public get url() { + return this.clientOptions.url!; } constructor(readonly clientOptions: SquidexOptions) { @@ -257,6 +256,10 @@ export class SquidexClients { throw new Error("Configuration 'appName' is required."); } + clientOptions.url ||= 'https://cloud.squidex.io'; + + Object.freeze(clientOptions); + this.tokenStore = this.clientOptions.tokenStore || new InMemoryTokenStore(); const fetchCore = this.clientOptions.fetcher || fetch; @@ -303,7 +306,7 @@ export class SquidexClients { }; const parameters: ConfigurationParameters = { - basePath: clientOptions.environment || "https://cloud.squidex.io", + basePath: clientOptions.url || "https://cloud.squidex.io", fetchApi, }; @@ -330,8 +333,8 @@ function addOptions(init: RequestInit, clientOptions: SquidexOptions) { init.signal = AbortSignal.timeout(clientOptions.timeout); } - if (clientOptions.customHeader) { - for (const [key, value] of Object.entries(clientOptions.customHeader)) { + if (clientOptions.customHeaders) { + for (const [key, value] of Object.entries(clientOptions.customHeaders)) { addHeader(init, key, value); } } diff --git a/tests/_utils.ts b/tests/_utils.ts index f7d49b0..9169865 100644 --- a/tests/_utils.ts +++ b/tests/_utils.ts @@ -14,7 +14,7 @@ export function getClient() { const appName = getEnvironment("CONFIG__APP__NAME", "integrations-tests"); const clientId = getEnvironment("CONFIG__CLIENT__ID", "root"); const clientSecret = getEnvironment("CONFIG__CLIENT__SECRET", "xeLd6jFxqbXJrfmNLlO2j1apagGGGSyZJhFnIuHp4I0="); - const environment = getEnvironment("CONFIG__SERVER__URL", "https://localhost:5001"); + const url = getEnvironment("CONFIG__SERVER__URL", "https://localhost:5001"); const middleware: SquidexOptions["middleware"] = { pre: async (params) => { @@ -32,7 +32,7 @@ export function getClient() { appName, clientId, clientSecret, - environment, + url, middleware, }); @@ -41,7 +41,7 @@ export function getClient() { appName: app, clientId, clientSecret, - environment, + url, middleware, }); };