import { ILocale } from "./locale";
import { AbortController } from "node-abort-controller";

export interface IEnSrvOptions {
  enSrvUrl: string;
  namespace: string;
  sessionToken?: string;
  initialSessionToken?: string;
  maintainInitialSessionToken?: boolean;
  debug?: boolean;

  // defaults to true - extracts the session id from the sessionToken and persist the session at the server.
  // false - Server creates a new session
  useCurrentSession?: boolean;

  useSharedAnonymousSession?: boolean;

  // The end-client IP and via to send to EnSrv
  // This is critical for whitelist checking
  clientIp?: string;
  clientVia?: string;

  // Indicates that the operations being sent are bulk in nature, so EnSrv should optimise "watching",
  // and other flow on effects. Note this may only be actually honoured by EnSrv if coming from a trusted origin.
  bulk?: boolean;

  // If true, uses the query service for queries
  useQueryService?: boolean;

  locale?: ILocale;

  // Used to send additional
  additionalQueryString?: { [key: string]: string };

  // Used to send additional headers to EnSrv in requests
  additionalHeaders?: { [key: string]: string[] };

  // Used to abort EnSrv requests
  abortController?: AbortController;
}

export type IEnSrvOptionsLite = Omit<
  IEnSrvOptions,
  "enSrvUrl" | "namespace"
> & { enSrvUrl?: string; namespace?: string };
