UNPKG

contentful-sdk-core

Version:
1 lines 42.9 kB
{"version":3,"file":"index.cjs","sources":["../../src/async-token.ts","../../src/utils.ts","../../src/rate-limit.ts","../../src/pThrottle.ts","../../src/rate-limit-throttle.ts","../../src/create-default-options.ts","../../src/create-http-client.ts","../../src/create-request-config.ts","../../src/enforce-obj-path.ts","../../src/freeze-sys.ts","../../src/get-user-agent.ts","../../src/to-plain-object.ts","../../src/error-handler.ts"],"sourcesContent":["import type { AxiosInstance } from './types.js'\n\nexport default function asyncToken(instance: AxiosInstance, getToken: () => Promise<string>): void {\n instance.interceptors.request.use(function (config) {\n return getToken().then((accessToken) => {\n config.headers.set('Authorization', `Bearer ${accessToken}`)\n return config\n })\n })\n}\n","import process from 'process'\n\nexport function isNode(): boolean {\n /**\n * Polyfills of 'process' might set process.browser === true\n *\n * See:\n * https://github.com/webpack/node-libs-browser/blob/master/mock/process.js#L8\n * https://github.com/defunctzombie/node-process/blob/master/browser.js#L156\n **/\n return typeof process !== 'undefined' && !(process as any).browser\n}\n\nexport function isReactNative(): boolean {\n return (\n typeof window !== 'undefined' &&\n 'navigator' in window &&\n 'product' in window.navigator &&\n window.navigator.product === 'ReactNative'\n )\n}\n\nexport function getNodeVersion(): string {\n return process.versions && process.versions.node ? `v${process.versions.node}` : process.version\n}\n\nexport function getWindow(): Window {\n return window\n}\n\nexport function noop(): undefined {\n return undefined\n}\n","import { noop } from './utils.js'\nimport type { AxiosInstance } from './types.js'\n\nconst delay = (ms: number): Promise<void> =>\n new Promise((resolve) => {\n setTimeout(resolve, ms)\n })\n\nconst defaultWait = (attempts: number): number => {\n return Math.pow(Math.SQRT2, attempts)\n}\n\nexport default function rateLimit(instance: AxiosInstance, maxRetry = 5): void {\n const { responseLogger = noop, requestLogger = noop } = instance.defaults\n\n instance.interceptors.request.use(\n function (config) {\n requestLogger(config)\n return config\n },\n function (error) {\n requestLogger(error)\n return Promise.reject(error)\n },\n )\n\n instance.interceptors.response.use(\n function (response) {\n // we don't need to do anything here\n responseLogger(response)\n return response\n },\n async function (error) {\n const { response } = error\n const { config } = error\n responseLogger(error)\n // Do not retry if it is disabled or no request config exists (not an axios error)\n if (!config || !instance.defaults.retryOnError) {\n return Promise.reject(error)\n }\n\n // Retried already for max attempts\n const doneAttempts = config.attempts || 1\n if (doneAttempts > maxRetry) {\n error.attempts = config.attempts\n return Promise.reject(error)\n }\n\n let retryErrorType = null\n let wait = defaultWait(doneAttempts)\n\n // Errors without response did not receive anything from the server\n if (!response) {\n retryErrorType = 'Connection'\n } else if (response.status >= 500 && response.status < 600) {\n // 5** errors are server related\n retryErrorType = `Server ${response.status}`\n } else if (response.status === 429) {\n // 429 errors are exceeded rate limit exceptions\n retryErrorType = 'Rate limit'\n // all headers are lowercased by axios https://github.com/mzabriskie/axios/issues/413\n if (response.headers && error.response.headers['x-contentful-ratelimit-reset']) {\n wait = response.headers['x-contentful-ratelimit-reset']\n }\n }\n\n if (retryErrorType) {\n // convert to ms and add jitter\n wait = Math.floor(wait * 1000 + Math.random() * 200 + 500)\n instance.defaults.logHandler(\n 'warning',\n `${retryErrorType} error occurred. Waiting for ${wait} ms before retrying...`,\n )\n\n // increase attempts counter\n config.attempts = doneAttempts + 1\n\n /* Somehow between the interceptor and retrying the request the httpAgent/httpsAgent gets transformed from an Agent-like object\n to a regular object, causing failures on retries after rate limits. Removing these properties here fixes the error, but retry\n requests still use the original http/httpsAgent property */\n delete config.httpAgent\n delete config.httpsAgent\n\n return delay(wait).then(() => instance(config))\n }\n return Promise.reject(error)\n },\n )\n}\n","export class AbortError extends Error {\n readonly name = 'AbortError' as const\n\n constructor() {\n super('Throttled function aborted')\n }\n}\n\ntype AnyFunction = (...arguments_: readonly any[]) => unknown\n\nexport type ThrottledFunction<F extends AnyFunction> = F & {\n /**\n * Whether future function calls should be throttled or count towards throttling thresholds.\n *\n * @default true\n */\n isEnabled: boolean\n\n /**\n * The number of queued items waiting to be executed.\n */\n readonly queueSize: number\n\n /**\n * Abort pending executions. All unresolved promises are rejected with a `pThrottle.AbortError` error.\n */\n abort(): void\n}\n\nexport type Options = {\n /**\n * The maximum number of calls within an `interval`.\n */\n readonly limit: number\n\n /**\n * The timespan for `limit` in milliseconds.\n */\n readonly interval: number\n\n /**\n * Use a strict, more resource intensive, throttling algorithm. The default algorithm uses a windowed approach that will work correctly in most cases, limiting the total number of calls at the specified limit per interval window. The strict algorithm throttles each call individually, ensuring the limit is not exceeded for any interval.\n *\n * @default false\n */\n readonly strict?: boolean\n\n /**\n * Get notified when function calls are delayed due to exceeding the `limit` of allowed calls within the given `interval`.\n *\n * Can be useful for monitoring the throttling efficiency.\n *\n * @example\n * ```\n * import pThrottle from './PThrottle';\n *\n * const throttle = pThrottle({\n * limit: 2,\n * interval: 1000,\n * onDelay: () => {\n * console.log('Reached interval limit, call is delayed');\n * },\n * });\n *\n * const throttled = throttle(() => {\n * console.log('Executing...');\n * });\n *\n * await throttled();\n * await throttled();\n * await throttled();\n * //=> Executing...\n * //=> Executing...\n * //=> Reached interval limit, call is delayed\n * //=> Executing...\n * ```\n */\n readonly onDelay?: () => void\n}\n\n/**\n * Throttle promise-returning/async/normal functions.\n *\n * It rate-limits function calls without discarding them, making it ideal for external API interactions where avoiding call loss is crucial.\n *\n * @returns A throttle function.\n *\n * Both the `limit` and `interval` options must be specified.\n *\n * @example\n * ```\n * import pThrottle from './PThrottle';\n *\n * const now = Date.now();\n *\n * const throttle = pThrottle({\n * limit: 2,\n * interval: 1000\n * });\n *\n * const throttled = throttle(async index => {\n * const secDiff = ((Date.now() - now) / 1000).toFixed();\n * return `${index}: ${secDiff}s`;\n * });\n *\n * for (let index = 1; index <= 6; index++) {\n * (async () => {\n * console.log(await throttled(index));\n * })();\n * }\n * //=> 1: 0s\n * //=> 2: 0s\n * //=> 3: 1s\n * //=> 4: 1s\n * //=> 5: 2s\n * //=> 6: 2s\n * ```\n */\nexport default function pThrottle({ limit, interval, strict, onDelay }: Options) {\n if (!Number.isFinite(limit)) {\n throw new TypeError('Expected `limit` to be a finite number')\n }\n\n if (!Number.isFinite(interval)) {\n throw new TypeError('Expected `interval` to be a finite number')\n }\n\n const queue = new Map<NodeJS.Timeout, (error: AbortError) => void>()\n\n let currentTick = 0\n let activeCount = 0\n\n function windowedDelay() {\n const now = Date.now()\n\n if (now - currentTick > interval) {\n activeCount = 1\n currentTick = now\n return 0\n }\n\n if (activeCount < limit) {\n activeCount++\n } else {\n currentTick += interval\n activeCount = 1\n }\n\n return currentTick - now\n }\n\n const strictTicks: number[] = []\n\n function strictDelay() {\n const now = Date.now()\n\n // Clear the queue if there's a significant delay since the last execution\n if (strictTicks.length > 0 && now - strictTicks.at(-1)! > interval) {\n strictTicks.length = 0\n }\n\n // If the queue is not full, add the current time and execute immediately\n if (strictTicks.length < limit) {\n strictTicks.push(now)\n return 0\n }\n\n // Calculate the next execution time based on the first item in the queue\n const nextExecutionTime = strictTicks[0] + interval\n\n // Shift the queue and add the new execution time\n strictTicks.shift()\n strictTicks.push(nextExecutionTime)\n\n // Calculate the delay for the current execution\n return Math.max(0, nextExecutionTime - now)\n }\n\n const getDelay = strict ? strictDelay : windowedDelay\n\n return function <F extends AnyFunction>(function_: F): ThrottledFunction<F> {\n const throttled = function (this: any, ...arguments_: any[]) {\n if (!throttled.isEnabled) {\n return (async () => function_.apply(this, arguments_))()\n }\n\n let timeoutId: NodeJS.Timeout\n return new Promise((resolve, reject) => {\n const execute = () => {\n resolve(function_.apply(this, arguments_))\n queue.delete(timeoutId)\n }\n\n const delay = getDelay()\n if (delay > 0) {\n timeoutId = setTimeout(execute, delay)\n queue.set(timeoutId, reject)\n onDelay?.()\n } else {\n execute()\n }\n })\n } as ThrottledFunction<F>\n\n throttled.abort = () => {\n for (const timeout of queue.keys()) {\n clearTimeout(timeout)\n queue.get(timeout)!(new AbortError())\n }\n\n queue.clear()\n strictTicks.splice(0, strictTicks.length)\n }\n\n throttled.isEnabled = true\n\n Object.defineProperty(throttled, 'queueSize', {\n get() {\n return queue.size\n },\n })\n\n return throttled\n }\n}\n","import isString from 'lodash/isString.js'\nimport pThrottle from './pThrottle.js'\n\nimport { AxiosInstance } from './types.js'\nimport { noop } from './utils.js'\n\ntype ThrottleType = 'auto' | string\n\nconst PERCENTAGE_REGEX = /(?<value>\\d+)(%)/\n\nfunction calculateLimit(type: ThrottleType, max = 7) {\n let limit = max\n\n if (PERCENTAGE_REGEX.test(type)) {\n const groups = type.match(PERCENTAGE_REGEX)?.groups\n if (groups && groups.value) {\n const percentage = parseInt(groups.value) / 100\n limit = Math.round(max * percentage)\n }\n }\n return Math.min(30, Math.max(1, limit))\n}\n\nfunction createThrottle(limit: number, logger: (...args: any[]) => void) {\n logger('info', `Throttle request to ${limit}/s`)\n return pThrottle({\n limit,\n interval: 1000,\n strict: false,\n })\n}\n\nexport default (axiosInstance: AxiosInstance, type: ThrottleType | number = 'auto') => {\n const { logHandler = noop } = axiosInstance.defaults\n let limit = isString(type) ? calculateLimit(type) : calculateLimit('auto', type)\n let throttle = createThrottle(limit, logHandler)\n let isCalculated = false\n\n let requestInterceptorId = axiosInstance.interceptors.request.use(\n (config) => {\n return throttle(() => config)()\n },\n function (error) {\n return Promise.reject(error)\n },\n )\n\n const responseInterceptorId = axiosInstance.interceptors.response.use(\n (response) => {\n if (\n !isCalculated &&\n isString(type) &&\n (type === 'auto' || PERCENTAGE_REGEX.test(type)) &&\n response.headers &&\n response.headers['x-contentful-ratelimit-second-limit']\n ) {\n const rawLimit = parseInt(response.headers['x-contentful-ratelimit-second-limit'])\n const nextLimit = calculateLimit(type, rawLimit)\n\n if (nextLimit !== limit) {\n if (requestInterceptorId) {\n axiosInstance.interceptors.request.eject(requestInterceptorId)\n }\n\n limit = nextLimit\n\n throttle = createThrottle(nextLimit, logHandler)\n requestInterceptorId = axiosInstance.interceptors.request.use(\n (config) => {\n return throttle(() => config)()\n },\n function (error) {\n return Promise.reject(error)\n },\n )\n }\n\n isCalculated = true\n }\n\n return response\n },\n function (error) {\n return Promise.reject(error)\n },\n )\n\n return () => {\n axiosInstance.interceptors.request.eject(requestInterceptorId)\n axiosInstance.interceptors.response.eject(responseInterceptorId)\n }\n}\n","import { CreateHttpClientParams, DefaultOptions } from './types'\nimport { AxiosRequestHeaders } from 'axios'\nimport qs from 'qs'\n\n// Matches 'sub.host:port' or 'host:port' and extracts hostname and port\n// Also enforces toplevel domain specified, no spaces and no protocol\nconst HOST_REGEX = /^(?!\\w+:\\/\\/)([^\\s:]+\\.?[^\\s:]+)(?::(\\d+))?(?!:)$/\n\n/**\n * Create default options\n * @private\n * @param {CreateHttpClientParams} options - Initialization parameters for the HTTP client\n * @return {DefaultOptions} options to pass to axios\n */\nexport default function createDefaultOptions(options: CreateHttpClientParams): DefaultOptions {\n const defaultConfig = {\n insecure: false as const,\n retryOnError: true as const,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n logHandler: (level: string, data: any): void => {\n if (level === 'error' && data) {\n const title = [data.name, data.message].filter((a) => a).join(' - ')\n console.error(`[error] ${title}`)\n console.error(data)\n return\n }\n console.log(`[${level}] ${data}`)\n },\n // Passed to axios\n headers: {} as AxiosRequestHeaders,\n httpAgent: false as const,\n httpsAgent: false as const,\n timeout: 30000,\n throttle: 0,\n basePath: '',\n adapter: undefined,\n maxContentLength: 1073741824, // 1GB\n maxBodyLength: 1073741824, // 1GB\n }\n const config = {\n ...defaultConfig,\n ...options,\n }\n\n if (!config.accessToken) {\n const missingAccessTokenError = new TypeError('Expected parameter accessToken')\n config.logHandler('error', missingAccessTokenError)\n throw missingAccessTokenError\n }\n\n // Construct axios baseURL option\n const protocol = config.insecure ? 'http' : 'https'\n const space = config.space ? `${config.space}/` : ''\n let hostname = config.defaultHostname\n let port: number | string = config.insecure ? 80 : 443\n if (config.host && HOST_REGEX.test(config.host)) {\n const parsed = config.host.split(':')\n if (parsed.length === 2) {\n ;[hostname, port] = parsed\n } else {\n hostname = parsed[0]\n }\n }\n\n // Ensure that basePath does start but not end with a slash\n if (config.basePath) {\n config.basePath = `/${config.basePath.split('/').filter(Boolean).join('/')}`\n }\n\n const baseURL =\n options.baseURL || `${protocol}://${hostname}:${port}${config.basePath}/spaces/${space}`\n\n if (!config.headers.Authorization && typeof config.accessToken !== 'function') {\n config.headers.Authorization = 'Bearer ' + config.accessToken\n }\n\n const axiosOptions: DefaultOptions = {\n // Axios\n baseURL,\n headers: config.headers,\n httpAgent: config.httpAgent,\n httpsAgent: config.httpsAgent,\n proxy: config.proxy,\n timeout: config.timeout,\n adapter: config.adapter,\n fetchOptions: config.fetchOptions,\n maxContentLength: config.maxContentLength,\n maxBodyLength: config.maxBodyLength,\n paramsSerializer: {\n serialize: (params) => {\n return qs.stringify(params)\n },\n },\n // Contentful\n logHandler: config.logHandler,\n responseLogger: config.responseLogger,\n requestLogger: config.requestLogger,\n retryOnError: config.retryOnError,\n }\n return axiosOptions\n}\n","import type { AxiosStatic } from 'axios'\nimport copy from 'fast-copy'\n\nimport asyncToken from './async-token.js'\nimport rateLimitRetry from './rate-limit.js'\nimport rateLimitThrottle from './rate-limit-throttle.js'\nimport type { AxiosInstance, CreateHttpClientParams } from './types.js'\nimport createDefaultOptions from './create-default-options.js'\n\nfunction copyHttpClientParams(options: CreateHttpClientParams): CreateHttpClientParams {\n const copiedOptions = copy(options)\n // httpAgent and httpsAgent cannot be copied because they can contain private fields\n copiedOptions.httpAgent = options.httpAgent\n copiedOptions.httpsAgent = options.httpsAgent\n return copiedOptions\n}\n\n/**\n * Create pre-configured axios instance\n * @private\n * @param {AxiosStatic} axios - Axios library\n * @param {CreateHttpClientParams} options - Initialization parameters for the HTTP client\n * @return {AxiosInstance} Initialized axios instance\n */\nexport default function createHttpClient(\n axios: AxiosStatic,\n options: CreateHttpClientParams,\n): AxiosInstance {\n const axiosOptions = createDefaultOptions(options)\n\n const instance = axios.create(axiosOptions) as AxiosInstance\n instance.httpClientParams = options\n\n /**\n * Creates a new axios instance with the same default base parameters as the\n * current one, and with any overrides passed to the newParams object\n * This is useful as the SDKs use dependency injection to get the axios library\n * and the version of the library comes from different places depending\n * on whether it's a browser build or a node.js build.\n * @private\n * @param {CreateHttpClientParams} newParams - Initialization parameters for the HTTP client\n * @return {AxiosInstance} Initialized axios instance\n */\n instance.cloneWithNewParams = function (\n newParams: Partial<CreateHttpClientParams>,\n ): AxiosInstance {\n return createHttpClient(axios, {\n ...copyHttpClientParams(options),\n ...newParams,\n })\n }\n\n /**\n * Apply interceptors.\n * Please note that the order of interceptors is important\n */\n\n if (options.onBeforeRequest) {\n instance.interceptors.request.use(options.onBeforeRequest)\n }\n\n if (typeof options.accessToken === 'function') {\n asyncToken(instance, options.accessToken)\n }\n\n if (options.throttle) {\n rateLimitThrottle(instance, options.throttle)\n }\n rateLimitRetry(instance, options.retryLimit)\n\n if (options.onError) {\n instance.interceptors.response.use((response) => response, options.onError)\n }\n\n return instance\n}\n","import copy from 'fast-copy'\n\ntype Config = {\n params?: Record<string, any>\n}\n\n/**\n * Creates request parameters configuration by parsing an existing query object\n * @private\n * @param {Object} query\n * @return {Object} Config object with `params` property, ready to be used in axios\n */\nexport default function createRequestConfig({ query }: { query: Record<string, any> }): Config {\n const config: Config = {}\n delete query.resolveLinks\n config.params = copy(query)\n return config\n}\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport default function enforceObjPath(obj: any, path: string): boolean {\n if (!(path in obj)) {\n const err = new Error()\n err.name = 'PropertyMissing'\n err.message = `Required property ${path} missing from:\n\n${JSON.stringify(obj)}\n\n`\n throw err\n }\n return true\n}\n","// copied from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze\n\ntype FreezeObject = Record<string, any>\n\nfunction deepFreeze<T extends FreezeObject>(object: T): T {\n const propNames = Object.getOwnPropertyNames(object)\n\n for (const name of propNames) {\n const value = object[name]\n\n if (value && typeof value === 'object') {\n deepFreeze(value)\n }\n }\n\n return Object.freeze(object)\n}\n\nexport default function freezeSys<T extends FreezeObject>(obj: T): T {\n deepFreeze(obj.sys || {})\n return obj\n}\n","import process from 'process'\n\nimport { isNode, getNodeVersion, isReactNative, getWindow } from './utils.js'\n\nfunction getBrowserOS(): string | null {\n const win = getWindow()\n if (!win) {\n return null\n }\n const userAgent = win.navigator.userAgent\n // TODO: platform is deprecated.\n const platform = win.navigator.platform\n const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K']\n const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE']\n const iosPlatforms = ['iPhone', 'iPad', 'iPod']\n\n if (macosPlatforms.indexOf(platform) !== -1) {\n return 'macOS'\n } else if (iosPlatforms.indexOf(platform) !== -1) {\n return 'iOS'\n } else if (windowsPlatforms.indexOf(platform) !== -1) {\n return 'Windows'\n } else if (/Android/.test(userAgent)) {\n return 'Android'\n } else if (/Linux/.test(platform)) {\n return 'Linux'\n }\n\n return null\n}\n\ntype PlatformMap = Record<string, 'Android' | 'Linux' | 'Windows' | 'macOS'>\n\nfunction getNodeOS(): string | null {\n const platform = process.platform || 'linux'\n const version = process.version || '0.0.0'\n const platformMap: PlatformMap = {\n android: 'Android',\n aix: 'Linux',\n darwin: 'macOS',\n freebsd: 'Linux',\n linux: 'Linux',\n openbsd: 'Linux',\n sunos: 'Linux',\n win32: 'Windows',\n }\n if (platform in platformMap) {\n return `${platformMap[platform] || 'Linux'}/${version}`\n }\n return null\n}\n\nexport default function getUserAgentHeader(\n sdk: string,\n application?: string,\n integration?: string,\n feature?: string,\n): string {\n const headerParts = []\n\n if (application) {\n headerParts.push(`app ${application}`)\n }\n\n if (integration) {\n headerParts.push(`integration ${integration}`)\n }\n\n if (feature) {\n headerParts.push('feature ' + feature)\n }\n\n headerParts.push(`sdk ${sdk}`)\n\n let platform = null\n try {\n if (isReactNative()) {\n platform = getBrowserOS()\n headerParts.push('platform ReactNative')\n } else if (isNode()) {\n platform = getNodeOS()\n headerParts.push(`platform node.js/${getNodeVersion()}`)\n } else {\n platform = getBrowserOS()\n headerParts.push('platform browser')\n }\n } catch (e) {\n platform = null\n }\n\n if (platform) {\n headerParts.push(`os ${platform}`)\n }\n\n return `${headerParts.filter((item) => item !== '').join('; ')};`\n}\n","import copy from 'fast-copy'\n\n/**\n * Mixes in a method to return just a plain object with no additional methods\n * @private\n * @param data - Any plain JSON response returned from the API\n * @return Enhanced object with toPlainObject method\n */\nexport default function toPlainObject<T = Record<string, unknown>, R = T>(\n data: T,\n): T & {\n /**\n * Returns this entity as a plain JS object\n */\n toPlainObject(): R\n} {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error\n return Object.defineProperty(data, 'toPlainObject', {\n enumerable: false,\n configurable: false,\n writable: false,\n value: function () {\n return copy(this)\n },\n })\n}\n","import isPlainObject from 'lodash/isPlainObject.js'\nimport type { ContentfulErrorData } from './types.js'\n\nfunction obscureHeaders(config: any) {\n // Management, Delivery and Preview API tokens\n if (config?.headers?.['Authorization']) {\n const token = `...${config.headers['Authorization'].toString().substr(-5)}`\n config.headers['Authorization'] = `Bearer ${token}`\n }\n // Encoded Delivery or Preview token map for Cross-Space References\n if (config?.headers?.['X-Contentful-Resource-Resolution']) {\n const token = `...${config.headers['X-Contentful-Resource-Resolution'].toString().substr(-5)}`\n config.headers['X-Contentful-Resource-Resolution'] = token\n }\n}\n\n/**\n * Handles errors received from the server. Parses the error into a more useful\n * format, places it in an exception and throws it.\n * See https://www.contentful.com/developers/docs/references/errors/\n * for more details on the data received on the errorResponse.data property\n * and the expected error codes.\n * @private\n */\nexport default function errorHandler(errorResponse: any): never {\n const { config, response } = errorResponse\n let errorName\n\n obscureHeaders(config)\n\n if (!isPlainObject(response) || !isPlainObject(config)) {\n throw errorResponse\n }\n\n const data = response?.data\n\n const errorData: ContentfulErrorData = {\n status: response?.status,\n statusText: response?.statusText,\n message: '',\n details: {},\n }\n\n if (config && isPlainObject(config)) {\n errorData.request = {\n url: config.url,\n headers: config.headers,\n method: config.method,\n payloadData: config.data,\n }\n }\n if (data && typeof data === 'object') {\n if ('requestId' in data) {\n errorData.requestId = data.requestId || 'UNKNOWN'\n }\n if ('message' in data) {\n errorData.message = data.message || ''\n }\n if ('details' in data) {\n errorData.details = data.details || {}\n }\n errorName = data.sys?.id\n }\n\n const error = new Error()\n error.name =\n errorName && errorName !== 'Unknown' ? errorName : `${response?.status} ${response?.statusText}`\n\n try {\n error.message = JSON.stringify(errorData, null, ' ')\n } catch {\n error.message = errorData?.message ?? ''\n }\n throw error\n}\n"],"names":["process","isString","qs","copy","rateLimitRetry","isPlainObject"],"mappings":";;;;;;;;;;;;;;;;AAEc,SAAU,UAAU,CAAC,QAAuB,EAAE,QAA+B,EAAA;IACzF,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,MAAM,EAAA;QAChD,OAAO,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,WAAW,KAAI;YACrC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,CAAA,OAAA,EAAU,WAAW,CAAA,CAAE,CAAC;AAC5D,YAAA,OAAO,MAAM;AACf,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC,CAAC;AACJ;;SCPgB,MAAM,GAAA;AACpB;;;;;;AAMI;IACJ,OAAO,OAAOA,wBAAO,KAAK,WAAW,IAAI,CAAEA,wBAAe,CAAC,OAAO;AACpE;SAEgB,aAAa,GAAA;AAC3B,IAAA,QACE,OAAO,MAAM,KAAK,WAAW;AAC7B,QAAA,WAAW,IAAI,MAAM;QACrB,SAAS,IAAI,MAAM,CAAC,SAAS;AAC7B,QAAA,MAAM,CAAC,SAAS,CAAC,OAAO,KAAK,aAAa;AAE9C;SAEgB,cAAc,GAAA;IAC5B,OAAOA,wBAAO,CAAC,QAAQ,IAAIA,wBAAO,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAIA,wBAAO,CAAC,QAAQ,CAAC,IAAI,CAAA,CAAE,GAAGA,wBAAO,CAAC,OAAO;AAClG;SAEgB,SAAS,GAAA;AACvB,IAAA,OAAO,MAAM;AACf;SAEgB,IAAI,GAAA;AAClB,IAAA,OAAO,S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