package.cjs.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","_interopRequireDefault","require","_i18next","_neetoCist","_Toastr","_ramda","_reactToastify","_useDisplayErrorPage","_axios2","_paramsSerializer","_constants","checkOnlineInterval","requestErrorToasts","shouldNot","skip","_typeof2","shouldShowToastr","response","isNotEmpty","notice","noticeCode","setAuthHeaders","_document$querySelect","_axios$defaults$heade","axios","defaults","headers","_defineProperty2","HEADERS_KEYS","accept","contentType","xCsrfToken","document","querySelector","getAttribute","createPipe","functions","data","reduce","acc","fn","transformResponseKeysToCamelCase","_response$config$tran","config","transformResponseCase","keysToCamelCase","transformErrorKeysToCamelCase","error","_error$config","_error$response","_ref","_ref$transformRespons","showSuccessToastr","_response$config","_response$config$show","showToastr","requestUrl","url","requestMethod","method","toastIdKey","concat","errorToastId","toast","dismiss","dissoc","matches","showThumbsUpToastr","Toastr","success","icon","className","pullDataFromResponse","_response$config$incl","includeMetadataInResponse","buildSuccessResponseHandler","interceptors","transformCase","push","handleUnauthorizedErrorResponse","_error$response2","_error$config2","status","resetAuthTokens","_ref2","_ref2$redirectOnError","redirectOnError","setTimeout","redirectTo","window","location","pathname","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","i18next","t","dismissToastInterval","setInterval","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","MAXIMUM_OFFLINE_DURATION","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","useErrorDisplayStore","setState","showErrorPage","statusCode","failedApiUrl","failedApiPath","buildErrorResponseHandler","logoutOn401","Promise","reject","bind","cleanupCredentialsForCrossOrigin","hostname","evolve","omit","transformDataToSnakeCase","_request$transformReq","transformRequestCase","serializeKeysToSnakeCase","params","addRequestInterceptors","cleanCredentialsForCrossOrigin","use","addResponseInterceptors","registerIntercepts","initializeAxios","baseURL","authHeaders","paramsSerializer","setParamsSerializer"],"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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAKmB,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEnB,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAEA,IAAAQ,iBAAA,GAAAT,sBAAA,CAAAC,OAAA;AAEA,IAAAS,UAAA,GAAAT,OAAA;AAEA,IAAIU,mBAAmB,GAAG,IAAI;AAC9B,IAAIC,kBAAkB,GAAG,CAAC,CAAC;AAE3B,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAGC,IAAI;EAAA,OAAI,IAAAC,QAAA,aAAOD,IAAI,MAAK,QAAQ,IAAI,CAACA,IAAI;AAAA;AAE3D,IAAME,gBAAgB,GAAG,SAAnBA,gBAAgBA,CAAGC,QAAQ;EAAA,OAC9B,OAAOA,QAAQ,KAAK,QAAQ,IAAI,IAAAC,qBAAU,EAACD,QAAQ,CAAC,IACpD,IAAAF,QAAA,aAAOE,QAAQ,MAAK,QAAQ,KAAK,CAAAA,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEE,MAAM,MAAIF,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEG,UAAU,EAAE;AAAA;AAE9E,IAAMC,cAAc,GAAG,SAAjBA,cAAcA,CAAA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