diff --git a/packages/sdk/index.ts b/packages/sdk/index.ts index 74673a4e..f18680c5 100644 --- a/packages/sdk/index.ts +++ b/packages/sdk/index.ts @@ -4,7 +4,7 @@ import type { ProfilePayload, } from '@mixan/types'; -interface NewMixanOptions { +export interface NewMixanOptions { url: string; clientId: string; clientSecret: string; @@ -16,7 +16,7 @@ interface NewMixanOptions { getProfileId: () => string | null; removeProfileId: () => void; } -type MixanOptions = Required; +export type MixanOptions = Required; class Fetcher { private url: string; @@ -38,6 +38,8 @@ class Fetcher { ): Promise { const url = `${this.url}${path}`; this.logger(`Mixan request: ${url}`, JSON.stringify(data, null, 2)); + + // eslint-disable-next-line @typescript-eslint/no-unsafe-call return fetch(url, { headers: { ['mixan-client-id']: this.clientId, @@ -46,6 +48,7 @@ class Fetcher { }, method: 'POST', body: JSON.stringify(data ?? {}), + keepalive: true, ...(options ?? {}), }) .then(async (res) => { @@ -82,7 +85,7 @@ class Fetcher { class Batcher { queue: T[] = []; - timer?: NodeJS.Timeout; + timer?: ReturnType; callback: (queue: T[]) => void; maxBatchSize: number; batchInterval: number; diff --git a/packages/sdk/tsconfig.json b/packages/sdk/tsconfig.json index 1260b9f8..d539d24d 100644 --- a/packages/sdk/tsconfig.json +++ b/packages/sdk/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "lib": ["ESNext"], + "lib": ["ESNext", "DOM", "DOM.Iterable"], "module": "esnext", "target": "esnext", "moduleResolution": "bundler",