{"version":3,"sources":["../../src/mappersmith.ts"],"sourcesContent":["import { ClientBuilder, Client } from './client-builder'\nimport { assign } from './utils/index'\nimport { GlobalConfigs, ManifestOptions, ResourceTypeConstraint } from './manifest'\nimport { Context } from './middleware/index'\n\n/**\n * Can be used to test for `instanceof Response`\n */\nexport { Response } from './response'\n\nexport { version } from './version'\n\nexport const configs: GlobalConfigs = {\n  context: {},\n  middleware: [],\n  Promise: typeof Promise === 'function' ? Promise : null,\n  fetch: typeof fetch === 'function' ? fetch : null,\n\n  /**\n   * The maximum amount of executions allowed before it is considered an infinite loop.\n   * In the response phase of middleware, it's possible to execute a function called \"renew\",\n   * which can be used to rerun the middleware stack. This feature is useful in some scenarios,\n   * for example, re-fetching an invalid access token.\n\n   * This configuration is used to detect infinite loops, don't increase this value too much\n   * @default 2\n   */\n  maxMiddlewareStackExecutionAllowed: 2,\n\n  /**\n   * Gateway implementation, it defaults to \"lib/gateway/xhr\" for browsers and\n   * \"lib/gateway/http\" for node\n   */\n  gateway: null,\n  gatewayConfigs: {\n    /**\n     * Setting this option will fake PUT, PATCH and DELETE requests with a HTTP POST. It will\n     * add \"_method\" and \"X-HTTP-Method-Override\" with the original requested method\n     * @default false\n     */\n    emulateHTTP: false,\n\n    /**\n     * Setting this option will return HTTP status 408 (Request Timeout) when a request times\n     * out. When \"false\", HTTP status 400 (Bad Request) will be used instead.\n     * @default false\n     */\n    enableHTTP408OnTimeouts: false,\n\n    XHR: {\n      /**\n       * Indicates whether or not cross-site Access-Control requests should be made using credentials\n       * such as cookies, authorization headers or TLS client certificates.\n       * Setting withCredentials has no effect on same-site requests\n       *\n       * https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials\n       *\n       * @default false\n       */\n      withCredentials: false,\n\n      /**\n       * For additional configurations to the XMLHttpRequest object.\n       * @param {XMLHttpRequest} xhr\n       * @default null\n       */\n      configure: null,\n    },\n\n    HTTP: {\n      /**\n       * Enable this option to evaluate timeout on entire request durations,\n       * including DNS resolution and socket connection.\n       *\n       * See original nodejs issue: https://github.com/nodejs/node/pull/8101\n       *\n       * @default false\n       */\n      useSocketConnectionTimeout: false,\n      /**\n       * For additional configurations to the http/https module\n       * For http: https://nodejs.org/api/http.html#http_http_request_options_callback\n       * For https: https://nodejs.org/api/https.html#https_https_request_options_callback\n       *\n       * @param {object} options\n       * @default null\n       */\n      configure: null,\n      onRequestWillStart: null,\n      onRequestSocketAssigned: null,\n      onSocketLookup: null,\n      onSocketConnect: null,\n      onSocketSecureConnect: null,\n      onResponseReadable: null,\n      onResponseEnd: null,\n    },\n\n    Fetch: {\n      /**\n       * Indicates whether the user agent should send cookies from the other domain in the case of cross-origin\n       * requests. This is similar to XHR’s withCredentials flag, but with three available values (instead of two):\n       *\n       * \"omit\": Never send cookies.\n       * \"same-origin\": Only send cookies if the URL is on the same origin as the calling script.\n       * \"include\": Always send cookies, even for cross-origin calls.\n       *\n       * https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials\n       *\n       * @default \"omit\"\n       */\n      credentials: 'omit',\n    },\n  },\n}\n\n/**\n * @deprecated Shouldn't be used, not safe for concurrent use.\n * @param {Object} context\n */\nexport const setContext = (context: Context) => {\n  console.warn(\n    'The use of setContext is deprecated - you need to find another way to pass data between your middlewares.'\n  )\n  configs.context = assign(configs.context, context)\n}\n\nexport default function forge<Resources extends ResourceTypeConstraint>(\n  manifest: ManifestOptions<Resources>\n): Client<Resources> {\n  const GatewayClassFactory = () => configs.gateway\n  return new ClientBuilder(manifest, GatewayClassFactory, configs).build()\n}\n\nexport { forge }\n"],"mappings":";AAAA,SAAS,qBAA6B;AACtC,SAAS,cAAc;AAOvB,SAAS,gBAAgB;AAEzB,SAAS,eAAe;AAEjB,IAAM,UAAyB;AAAA,EACpC,SAAS,CAAC;AAAA,EACV,YAAY,CAAC;AAAA,EACb,SAAS,OAAO,YAAY,aAAa,UAAU;AAAA,EACnD,OAAO,OAAO,UAAU,aAAa,QAAQ;AAAA;AAAA;AAAA;AAAA;AAA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