package.initializers.axiosInitializer.index.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neeto-commons-frontend Show documentation
Show all versions of neeto-commons-frontend Show documentation
A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.
{"version":3,"file":"index.js","names":["axios","i18next","isNotEmpty","keysToCamelCase","matches","serializeKeysToSnakeCase","Toastr","dissoc","evolve","omit","toast","useErrorDisplayStore","resetAuthTokens","setParamsSerializer","HEADERS_KEYS","MAXIMUM_OFFLINE_DURATION","checkOnlineInterval","requestErrorToasts","shouldNot","skip","_typeof","shouldShowToastr","response","notice","noticeCode","setAuthHeaders","_document$querySelect","_axios$defaults$heade","defaults","headers","_defineProperty","accept","contentType","xCsrfToken","document","querySelector","getAttribute","createPipe","functions","data","reduce","acc","fn","transformResponseKeysToCamelCase","_response$config$tran","config","transformResponseCase","transformErrorKeysToCamelCase","error","_error$config","_error$response","_ref","_ref$transformRespons","showSuccessToastr","_response$config","_response$config$show","showToastr","requestUrl","url","requestMethod","method","toastIdKey","concat","errorToastId","dismiss","showThumbsUpToastr","success","icon","className","pullDataFromResponse","_response$config$incl","includeMetadataInResponse","buildSuccessResponseHandler","interceptors","transformCase","push","handleUnauthorizedErrorResponse","_error$response2","_error$config2","status","_ref2","_ref2$redirectOnError","redirectOnError","setTimeout","redirectTo","window","location","pathname","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","t","dismissToastInterval","setInterval","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref3$show422ErrorToa","show422ErrorToastr","_ref3$url","_ref3$method","_ref4","message","code","toastrContent","skippedStatusCodes","includes","isCancel","globalProps","railsEnv","getUrlPathName","URL","_unused","handle404ErrorResponse","_error$config4","_error$response4","_ref5","_ref5$show404ErrorPag","show404ErrorPage","_ref5$show403ErrorPag","show403ErrorPage","_error$request","fullUrl","request","responseURL","setState","showErrorPage","statusCode","failedApiUrl","failedApiPath","buildErrorResponseHandler","logoutOn401","Promise","reject","bind","cleanupCredentialsForCrossOrigin","hostname","transformDataToSnakeCase","_request$transformReq","transformRequestCase","params","addRequestInterceptors","cleanCredentialsForCrossOrigin","use","addResponseInterceptors","registerIntercepts","initializeAxios","baseURL","authHeaders","paramsSerializer"],"sources":["../../../src/initializers/axiosInitializer/index.js"],"sourcesContent":["import axios from \"axios\";\nimport i18next from \"i18next\";\nimport {\n isNotEmpty,\n keysToCamelCase,\n matches,\n serializeKeysToSnakeCase,\n} from \"neetocist\";\nimport { Toastr } from \"neetoui\";\nimport { dissoc, evolve, omit } from \"ramda\";\nimport { toast } from \"react-toastify\";\nimport { useErrorDisplayStore } from \"react-utils/useDisplayErrorPage\";\nimport { resetAuthTokens } from \"utils/axios\";\n\nimport setParamsSerializer from \"./paramsSerializer\";\n\nimport { HEADERS_KEYS, MAXIMUM_OFFLINE_DURATION } from \"../constants\";\n\nlet checkOnlineInterval = null;\nlet requestErrorToasts = {};\n\nconst shouldNot = skip => typeof skip === \"object\" || !skip;\n\nconst shouldShowToastr = response =>\n (typeof response === \"string\" && isNotEmpty(response)) ||\n (typeof response === \"object\" && (response?.notice || response?.noticeCode));\n\nconst setAuthHeaders = () => {\n // @ts-ignore\n axios.defaults.headers = {\n [HEADERS_KEYS.accept]: \"application/json\",\n [HEADERS_KEYS.contentType]: \"application/json\",\n [HEADERS_KEYS.xCsrfToken]: document\n .querySelector('[name=\"csrf-token\"]')\n ?.getAttribute(\"content\"),\n };\n};\n\n// pipe function from ramda doesn't accept array of functions.\n// We can't use spread operator too. So this is a workaround.\nconst createPipe = functions => data =>\n functions.reduce((acc, fn) => fn(acc), data);\n\nconst transformResponseKeysToCamelCase = response => {\n const { transformResponseCase = true } = response.config;\n\n if (response.data && transformResponseCase) {\n response.data = keysToCamelCase(response.data);\n }\n\n return response;\n};\n\nconst transformErrorKeysToCamelCase = error => {\n const { transformResponseCase = true } = error.config ?? {};\n\n if (error.response?.data && transformResponseCase) {\n error.response.data = keysToCamelCase(error.response.data);\n }\n\n return error;\n};\n\nconst showSuccessToastr = response => {\n const {\n showToastr = true,\n url: requestUrl,\n method: requestMethod,\n } = response.config;\n if (!showToastr) return response;\n\n const toastIdKey = `${requestMethod}:${requestUrl}`;\n const errorToastId = requestErrorToasts[toastIdKey];\n if (errorToastId) {\n toast.dismiss(errorToastId);\n requestErrorToasts = dissoc(toastIdKey, requestErrorToasts);\n }\n\n if (matches({ showThumbsUpToastr: true }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (matches({ noticeCode: \"thumbs_up\" }, response.data)) {\n // @ts-ignore\n Toastr.success(\"\", { icon: \"👍\", className: \"w-20\" });\n } else if (shouldShowToastr(response.data)) {\n Toastr.success(response.data);\n }\n\n return response;\n};\n\nconst pullDataFromResponse = response => {\n const { includeMetadataInResponse = false } = response.config;\n\n return includeMetadataInResponse ? response : response.data;\n};\n\nconst buildSuccessResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformResponseKeysToCamelCase);\n\n if (!skip?.showToastr) interceptors.push(showSuccessToastr);\n\n if (!skip?.pullDataFromResponse) interceptors.push(pullDataFromResponse);\n\n return createPipe(interceptors);\n};\n\nconst handleUnauthorizedErrorResponse = error => {\n if (error.response?.status !== 401) return error;\n\n resetAuthTokens();\n\n const { redirectOnError = true } = error.config ?? {};\n if (redirectOnError) {\n setTimeout(() => {\n const redirectTo =\n window.location.pathname === \"/login\"\n ? \"/login\"\n : `/login?redirect_uri=${encodeURIComponent(window.location.href)}`;\n\n // eslint-disable-next-line xss/no-location-href-assign\n window.location.href = redirectTo;\n }, 300);\n }\n\n return error;\n};\n\nconst isOnline = () => window.navigator.onLine;\n\nconst showOfflineToastr = () => {\n const toastId = Toastr.error(\n i18next.t(\"neetoCommons.toastr.error.networkError\")\n );\n\n if (toastId) {\n const dismissToastInterval = setInterval(() => {\n if (!isOnline()) return;\n\n toast.dismiss(toastId);\n clearInterval(dismissToastInterval);\n checkOnlineInterval = null;\n }, 1000);\n }\n};\n\nconst handleNetworkError = error => {\n if (checkOnlineInterval) return error;\n\n const startTime = Date.now();\n\n checkOnlineInterval = setInterval(() => {\n const elapsedTime = Date.now() - startTime;\n\n if (isOnline()) {\n clearInterval(checkOnlineInterval);\n checkOnlineInterval = null;\n } else if (elapsedTime >= MAXIMUM_OFFLINE_DURATION) {\n clearInterval(checkOnlineInterval);\n showOfflineToastr();\n }\n }, 1000);\n\n return error;\n};\n\nconst showErrorToastr = error => {\n const {\n showToastr = true,\n show422ErrorToastr = true,\n url: requestUrl = \"\",\n method: requestMethod = \"\",\n } = error.config ?? {};\n const { status } = error.response ?? {};\n\n if (!showToastr) return error;\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n let shouldShowToastr = false,\n toastrContent = error;\n\n const skippedStatusCodes = [403, 404, 520, 422];\n if (!skippedStatusCodes.includes(status) && !axios.isCancel(error)) {\n // we already display a page in case of 403 & 404 and we don't want to show a toastr for cancelled requests.\n // We handle cloudflare error differently for production and other environments.\n shouldShowToastr = true;\n }\n\n if (status === 422 && show422ErrorToastr) shouldShowToastr = true;\n\n if (status === 520) {\n shouldShowToastr = true;\n if (globalProps.railsEnv === \"production\") {\n toastrContent = i18next.t(\"generic.error\");\n }\n }\n\n const toastIdKey = `${requestMethod}:${requestUrl}`;\n const errorToastId = requestErrorToasts[toastIdKey];\n if (errorToastId) toast.dismiss(errorToastId);\n\n if (shouldShowToastr) {\n if (errorToastId) {\n // if there's an existing toastr with the same message, the onClose callback in the neetoUI which\n // removes the toastr from the unique list will be fired only after the toast is completely removed\n // from the UI. If there's no delay, the new toastr will be considered as duplicate and ignored.\n setTimeout(() => {\n requestErrorToasts[toastIdKey] = Toastr.error(toastrContent);\n }, 1200);\n } else requestErrorToasts[toastIdKey] = Toastr.error(toastrContent);\n }\n\n return error;\n};\n\nconst getUrlPathName = url => {\n try {\n return new URL(url).pathname;\n } catch {\n return url;\n }\n};\n\nconst handle404ErrorResponse = error => {\n const { show404ErrorPage = true, show403ErrorPage = true } =\n error.config ?? {};\n\n const status = error.response?.status;\n if (\n (status === 404 && show404ErrorPage) ||\n (status === 403 && show403ErrorPage)\n ) {\n const fullUrl = error.request?.responseURL || error.config.url;\n useErrorDisplayStore.setState({\n showErrorPage: true,\n statusCode: status,\n failedApiUrl: fullUrl,\n failedApiPath: getUrlPathName(fullUrl),\n });\n }\n\n return error;\n};\n\nconst buildErrorResponseHandler = skip => {\n const interceptors = [];\n if (!skip?.transformCase) interceptors.push(transformErrorKeysToCamelCase);\n\n if (!skip?.show404ErrorPage) interceptors.push(handle404ErrorResponse);\n\n if (!skip?.logoutOn401) interceptors.push(handleUnauthorizedErrorResponse);\n\n if (!skip?.showToastr) interceptors.push(showErrorToastr);\n\n interceptors.push(Promise.reject.bind(Promise));\n\n return createPipe(interceptors);\n};\n\nconst cleanupCredentialsForCrossOrigin = request => {\n if (!request.url.includes(\"://\")) return request;\n\n if (request.url.includes(window.location.hostname)) return request;\n\n return evolve({ headers: omit([HEADERS_KEYS.xCsrfToken]) })(request);\n};\n\nconst transformDataToSnakeCase = request => {\n const { transformRequestCase = true } = request;\n\n if (!transformRequestCase) return request;\n\n return evolve(\n { data: serializeKeysToSnakeCase, params: serializeKeysToSnakeCase },\n request\n );\n};\n\nconst addRequestInterceptors = skip => {\n if (!skip?.cleanCredentialsForCrossOrigin) {\n axios.interceptors.request.use(cleanupCredentialsForCrossOrigin);\n }\n\n if (!skip?.transformCase) {\n axios.interceptors.request.use(transformDataToSnakeCase);\n }\n};\n\nconst addResponseInterceptors = skip => {\n axios.interceptors.response.use(\n buildSuccessResponseHandler(skip),\n buildErrorResponseHandler(skip)\n );\n};\n\nconst registerIntercepts = skip => {\n if (shouldNot(skip?.request)) addRequestInterceptors(skip?.request);\n\n if (shouldNot(skip?.response)) addResponseInterceptors(skip?.response);\n};\n\nexport default function initializeAxios(skip) {\n if (!skip?.baseURL) axios.defaults.baseURL = \"/\";\n\n if (!skip?.authHeaders) setAuthHeaders();\n\n if (!skip?.paramsSerializer) setParamsSerializer();\n\n if (shouldNot(skip?.interceptors)) registerIntercepts(skip?.interceptors);\n}\n"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,OAAO,MAAM,SAAS;AAC7B,SACEC,UAAU,EACVC,eAAe,EACfC,OAAO,EACPC,wBAAwB;AACP,OAAAC,MAAA;AAEnB,SAASC,MAAM,EAAEC,MAAM,EAAEC,IAAI,QAAQ,OAAO;AAC5C,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,oBAAoB;AAC7B,SAASC,eAAe;AAExB,OAAOC,mBAAmB;AAE1B,SAASC,YAAY,EAAEC,wBAAwB;AAE/C,IAAIC,mBAAmB,GAAG,IAAI;AAC9B,IAAIC,kBAAkB,GAAG,CAAC,CAAC;AAE3B,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAGC,IAAI;EAAA,OAAIC,OAAA,CAAOD,IAAI,MAAK,QAAQ,IAAI,CAACA,IAAI;AAAA;AAE3D,IAAME,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAGC,QAAQ;EAAA,OAC9B,OAAOA,QAAQ,KAAK,QAAQ,IAAIpB,UAAU,CAACoB,QAAQ,CAAC,IACpDF,OAAA,CAAOE,QAAQ,MAAK,QAAQ,KAAK,CAAAA,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEC,MAAM,MAAID,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEE,UAAU,EAAE;AAAA;AAE9E,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAA,EAAS;EAAA,IAAAC,qBAAA,EAAAC,qBAAA;EAC3B;EACA3B,KAAK,CAAC4B,QAAQ,CAACC,OAAO,IAAAF,qBAAA,OAAAG,eAAA,CAAAH,qBAAA,EACnBb,YAAY,CAACiB,MAAM,EAAG,kBAAkB,GAAAD,e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