@bigbinary/neeto-commons-frontend 3.6.0-beta3 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/cjs/configs/babel.js +3 -29
  2. package/cjs/configs/constants.js +120 -0
  3. package/cjs/initializers/axiosInitializer/index.js +1 -1
  4. package/cjs/initializers/axiosInitializer/index.js.map +1 -1
  5. package/cjs/initializers/mixpanel.js +4 -2
  6. package/cjs/initializers/mixpanel.js.map +1 -1
  7. package/cjs/react-utils/useFetchNeetoApps/useFetchNeetoApps.js +1 -1
  8. package/cjs/react-utils/useFetchNeetoApps/useFetchNeetoApps.js.map +1 -1
  9. package/cjs/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js +4 -16
  10. package/cjs/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js.map +1 -1
  11. package/cjs/react-utils/usePersistedQuery/usePersistedQuery.js +2 -5
  12. package/cjs/react-utils/usePersistedQuery/usePersistedQuery.js.map +1 -1
  13. package/configs/babel.js +3 -29
  14. package/configs/constants.js +120 -0
  15. package/initializers/axiosInitializer/index.js +2 -2
  16. package/initializers/axiosInitializer/index.js.map +1 -1
  17. package/initializers/mixpanel.js +4 -2
  18. package/initializers/mixpanel.js.map +1 -1
  19. package/package.json +3 -3
  20. package/react-utils/useFetchNeetoApps/useFetchNeetoApps.js +1 -1
  21. package/react-utils/useFetchNeetoApps/useFetchNeetoApps.js.map +1 -1
  22. package/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js +4 -16
  23. package/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js.map +1 -1
  24. package/react-utils/usePersistedQuery/usePersistedQuery.js +2 -5
  25. package/react-utils/usePersistedQuery/usePersistedQuery.js.map +1 -1
  26. package/react-utils.d.ts +7 -17
@@ -1,3 +1,5 @@
1
+ const { TRANSFORM_RULES } = require("./constants");
2
+
1
3
  // eslint-disable-next-line @bigbinary/neeto/no-dangling-constants
2
4
  const VALID_ENVIRONMENTS = ["development", "test", "production"];
3
5
 
@@ -48,35 +50,7 @@ module.exports = function (api) {
48
50
  "babel-plugin-transform-react-remove-prop-types",
49
51
  { removeImport: true },
50
52
  ],
51
- [
52
- "transform-imports",
53
- {
54
- "@bigbinary/neetoui": {
55
- transform: "@bigbinary/neetoui/${member}",
56
- preventFullImport: true,
57
- },
58
- neetoui: {
59
- transform: "neetoui/${member}",
60
- preventFullImport: true,
61
- },
62
- "@bigbinary/neetoui/formik": {
63
- transform: "@bigbinary/neetoui/formik/${member}",
64
- preventFullImport: true,
65
- },
66
- "neetoui/formik": {
67
- transform: "neetoui/formik/${member}",
68
- preventFullImport: true,
69
- },
70
- "@bigbinary/neeto-thank-you-frontend": {
71
- transform: "@bigbinary/neeto-thank-you-frontend/${member}",
72
- preventFullImport: true,
73
- },
74
- neetothankyou: {
75
- transform: "neetothankyou/${member}",
76
- preventFullImport: true,
77
- },
78
- },
79
- ],
53
+ ...TRANSFORM_RULES,
80
54
  ].filter(Boolean),
81
55
  };
82
56
  };
@@ -0,0 +1,120 @@
1
+ const TRANSFORM_RULES = [
2
+ [
3
+ "transform-imports",
4
+ {
5
+ // neetoui
6
+ "@bigbinary/neetoui": {
7
+ transform: "@bigbinary/neetoui/${member}",
8
+ preventFullImport: true,
9
+ },
10
+ neetoui: {
11
+ transform: "neetoui/${member}",
12
+ preventFullImport: true,
13
+ },
14
+ "@bigbinary/neetoui/formik": {
15
+ transform: "@bigbinary/neetoui/formik/${member}",
16
+ preventFullImport: true,
17
+ },
18
+ "neetoui/formik": {
19
+ transform: "neetoui/formik/${member}",
20
+ preventFullImport: true,
21
+ },
22
+
23
+ // neeto-thank-you-frontend
24
+ "@bigbinary/neeto-thank-you-frontend": {
25
+ transform: "@bigbinary/neeto-thank-you-frontend/${member}",
26
+ preventFullImport: true,
27
+ },
28
+ neetothankyou: {
29
+ transform: "neetothankyou/${member}",
30
+ preventFullImport: true,
31
+ },
32
+
33
+ // neeto-payments-frontend
34
+ "@bigbinary/neeto-payments-frontend": {
35
+ transform: "@bigbinary/neeto-payments-frontend/${member}",
36
+ preventFullImport: true,
37
+ },
38
+ neetopayments: {
39
+ transform: "neetopayments/${member}",
40
+ preventFullImport: true,
41
+ },
42
+
43
+ // neeto-editor
44
+ "@bigbinary/neeto-editor": {
45
+ transform: importName => {
46
+ if (/^[A-Z][a-zA-Z]+$/.test(importName)) {
47
+ return `@bigbinary/neeto-editor/${importName}`;
48
+ }
49
+
50
+ return "@bigbinary/neeto-editor/utils";
51
+ },
52
+ preventFullImport: true,
53
+ skipDefaultConversion: true,
54
+ },
55
+ neetoeditor: {
56
+ transform: importName => {
57
+ if (/^[A-Z][a-zA-Z]+$/.test(importName)) {
58
+ return `neetoeditor/${importName}`;
59
+ }
60
+
61
+ return "neetoeditor/utils";
62
+ },
63
+ preventFullImport: true,
64
+ skipDefaultConversion: true,
65
+ },
66
+ "neetoeditor/([A-Z][a-zA-Z]+)$": {
67
+ transform: "neetoeditor/${member}",
68
+ preventFullImport: false,
69
+ },
70
+ "@bigbinary/neeto-editor/([A-Z][a-zA-Z]+)$": {
71
+ transform: "@bigbinary/neeto-editor/${member}",
72
+ preventFullImport: false,
73
+ },
74
+
75
+ // neeto-icons
76
+ "@bigbinary/neeto-icons": {
77
+ transform: "@bigbinary/neeto-icons/${member}",
78
+ preventFullImport: false,
79
+ },
80
+ neetoicons: {
81
+ transform: "neetoicons/${member}",
82
+ preventFullImport: false,
83
+ },
84
+ "@bigbinary/neeto-icons/typeface-logos": {
85
+ transform: "@bigbinary/neeto-icons/typeface-logos/${member}",
86
+ preventFullImport: false,
87
+ },
88
+ "neetoicons/typeface-logos": {
89
+ transform: "neetoicons/typeface-logos/${member}",
90
+ preventFullImport: false,
91
+ },
92
+ "@bigbinary/neeto-icons/app-icons": {
93
+ transform: "@bigbinary/neeto-icons/app-icons/${member}",
94
+ preventFullImport: false,
95
+ },
96
+ "neetoicons/app-icons": {
97
+ transform: "neetoicons/app-icons/${member}",
98
+ preventFullImport: false,
99
+ },
100
+ "@bigbinary/neeto-icons/neeto-logos": {
101
+ transform: "@bigbinary/neeto-icons/neeto-logos/${member}",
102
+ preventFullImport: false,
103
+ },
104
+ "neetoicons/neeto-logos": {
105
+ transform: "neetoicons/neeto-logos/${member}",
106
+ preventFullImport: false,
107
+ },
108
+ "@bigbinary/neeto-icons/misc": {
109
+ transform: "@bigbinary/neeto-icons/misc/${member}",
110
+ preventFullImport: false,
111
+ },
112
+ "neetoicons/misc": {
113
+ transform: "neetoicons/misc/${member}",
114
+ preventFullImport: false,
115
+ },
116
+ },
117
+ ],
118
+ ];
119
+
120
+ module.exports = { TRANSFORM_RULES };
@@ -22,7 +22,7 @@ var shouldNot = function shouldNot(skip) {
22
22
  return (0, _typeof2["default"])(skip) === "object" || !skip;
23
23
  };
24
24
  var shouldShowToastr = function shouldShowToastr(response) {
25
- return typeof response === "string" || (0, _typeof2["default"])(response) === "object" && ((response === null || response === void 0 ? void 0 : response.notice) || (response === null || response === void 0 ? void 0 : response.noticeCode));
25
+ return typeof response === "string" && (0, _neetoCist.isNotEmpty)(response) || (0, _typeof2["default"])(response) === "object" && ((response === null || response === void 0 ? void 0 : response.notice) || (response === null || response === void 0 ? void 0 : response.noticeCode));
26
26
  };
27
27
  var setAuthHeaders = function setAuthHeaders() {
28
28
  var _document$querySelect, _axios$defaults$heade;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_axios","_interopRequireDefault","require","_i18next","_neetoCist","_Toastr","_ramda","_reactToastify","_useDisplayErrorPage","_axios2","_paramsSerializer","_constants","checkOnlineInterval","shouldNot","skip","_typeof2","shouldShowToastr","response","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$show","showToastr","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","concat","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","i18next","t","dismissToastInterval","setInterval","toast","dismiss","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","MAXIMUM_OFFLINE_DURATION","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref4","message","code","includes","isCancel","globalProps","railsEnv","getUrlPathName","url","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 { keysToCamelCase, matches, serializeKeysToSnakeCase } from \"neetocist\";\nimport { Toastr } from \"neetoui\";\nimport { 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;\n\nconst shouldNot = skip => typeof skip === \"object\" || !skip;\n\nconst shouldShowToastr = response =>\n typeof response === \"string\" ||\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 { showToastr = true } = response.config;\n if (!showToastr) return response;\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 (isOnline()) {\n Toastr.error(i18next.t(\"generic.error\"));\n\n return error;\n }\n\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 { showToastr = true } = error.config ?? {};\n if (!showToastr) return error;\n\n const { status } = error.response ?? {};\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n if (![403, 404, 520].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 Toastr.error(error);\n }\n\n if (status === 520) {\n if (globalProps.railsEnv === \"production\") {\n Toastr.error(i18next.t(\"generic.error\"));\n } else Toastr.error(error);\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;AAA+E,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAE/E,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;AAE9B,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,OAC/B,OAAOA,QAAQ,KAAK,QAAQ,IAC3B,IAAAF,QAAA,aAAOE,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;EACAC,iBAAK,CAACC,QAAQ,CAACC,OAAO,IAAAH,qBAAA,WAAAI,gBAAA,aAAAJ,qBAAA,EACnBK,uBAAY,CAACC,MAAM,EAAG,kBAAkB,OAAAF,gBAAA,aAAAJ,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A,IAAI,CAAEG,QAAQ,CAAC;AACxE,CAAC;AAEc,SAASyI,eAAeA,CAAC5I,IAAI,EAAE;EAC5C,IAAI,EAACA,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE6I,OAAO,GAAEpI,iBAAK,CAACC,QAAQ,CAACmI,OAAO,GAAG,GAAG;EAEhD,IAAI,EAAC7I,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE8I,WAAW,GAAExI,cAAc,EAAE;EAExC,IAAI,EAACN,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE+I,gBAAgB,GAAE,IAAAC,4BAAmB,GAAE;EAElD,IAAIjJ,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEkD,YAAY,CAAC,EAAEyF,kBAAkB,CAAC3I,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEkD,YAAY,CAAC;AAC3E"}
1
+ {"version":3,"file":"index.js","names":["_axios","_interopRequireDefault","require","_i18next","_neetoCist","_Toastr","_ramda","_reactToastify","_useDisplayErrorPage","_axios2","_paramsSerializer","_constants","checkOnlineInterval","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$show","showToastr","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","concat","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","i18next","t","dismissToastInterval","setInterval","toast","dismiss","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","MAXIMUM_OFFLINE_DURATION","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref4","message","code","includes","isCancel","globalProps","railsEnv","getUrlPathName","url","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 { 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;\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 { showToastr = true } = response.config;\n if (!showToastr) return response;\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 (isOnline()) {\n Toastr.error(i18next.t(\"generic.error\"));\n\n return error;\n }\n\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 { showToastr = true } = error.config ?? {};\n if (!showToastr) return error;\n\n const { status } = error.response ?? {};\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n if (![403, 404, 520].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 Toastr.error(error);\n }\n\n if (status === 520) {\n if (globalProps.railsEnv === \"production\") {\n Toastr.error(i18next.t(\"generic.error\"));\n } else Toastr.error(error);\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;A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AC9I,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAE+I,WAAW,GAAExI,cAAc,EAAE;EAExC,IAAI,EAACP,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEgJ,gBAAgB,GAAE,IAAAC,4BAAmB,GAAE;EAElD,IAAIlJ,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEmD,YAAY,CAAC,EAAEyF,kBAAkB,CAAC5I,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEmD,YAAY,CAAC;AAC3E"}
@@ -10,10 +10,12 @@ function initializeMixpanel(skip) {
10
10
  var _globalProps$user, _globalProps$organiza;
11
11
  var analyticsId = "".concat((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email, "-").concat((_globalProps$organiza = globalProps.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.subdomain);
12
12
  if (globalProps.mixpanelProjectToken && !(skip !== null && skip !== void 0 && skip.mixpanel)) {
13
- var _globalProps$user2, _globalProps$organiza2;
13
+ var _globalProps$user2, _globalProps$user3, _globalProps$user4, _globalProps$organiza2;
14
14
  _mixpanelBrowser["default"].init(globalProps.mixpanelProjectToken);
15
15
  _mixpanelBrowser["default"].people.set({
16
- user: (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.email,
16
+ $first_name: (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.firstName,
17
+ $last_name: (_globalProps$user3 = globalProps.user) === null || _globalProps$user3 === void 0 ? void 0 : _globalProps$user3.lastName,
18
+ user: (_globalProps$user4 = globalProps.user) === null || _globalProps$user4 === void 0 ? void 0 : _globalProps$user4.email,
17
19
  subdomain: (_globalProps$organiza2 = globalProps.organization) === null || _globalProps$organiza2 === void 0 ? void 0 : _globalProps$organiza2.subdomain
18
20
  });
19
21
  _mixpanelBrowser["default"].identify(analyticsId);
@@ -1 +1 @@
1
- {"version":3,"file":"mixpanel.js","names":["_mixpanelBrowser","_interopRequireDefault","require","initializeMixpanel","skip","_globalProps$user","_globalProps$organiza","analyticsId","concat","globalProps","user","email","organization","subdomain","mixpanelProjectToken","mixpanel","_globalProps$user2","_globalProps$organiza2","init","people","set","identify"],"sources":["../../../src/initializers/mixpanel.js"],"sourcesContent":["import mixpanel from \"mixpanel-browser\";\n\nexport default function initializeMixpanel(skip) {\n const analyticsId = `${globalProps.user?.email}-${globalProps.organization?.subdomain}`;\n\n if (globalProps.mixpanelProjectToken && !skip?.mixpanel) {\n mixpanel.init(globalProps.mixpanelProjectToken);\n mixpanel.people.set({\n user: globalProps.user?.email,\n subdomain: globalProps.organization?.subdomain,\n });\n mixpanel.identify(analyticsId);\n } else {\n /*\n We need to initialize mixpanel with a bogus token in development and test environment to\n prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.\n */\n mixpanel.init(\"TEST_TOKEN\");\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEe,SAASC,kBAAkBA,CAACC,IAAI,EAAE;EAAA,IAAAC,iBAAA,EAAAC,qBAAA;EAC/C,IAAMC,WAAW,MAAAC,MAAA,EAAAH,iBAAA,GAAMI,WAAW,CAACC,IAAI,cAAAL,iBAAA,uBAAhBA,iBAAA,CAAkBM,KAAK,OAAAH,MAAA,EAAAF,qBAAA,GAAIG,WAAW,CAACG,YAAY,cAAAN,qBAAA,uBAAxBA,qBAAA,CAA0BO,SAAS,CAAE;EAEvF,IAAIJ,WAAW,CAACK,oBAAoB,IAAI,EAACV,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEW,QAAQ,GAAE;IAAA,IAAAC,kBAAA,EAAAC,sBAAA;IACvDF,2BAAQ,CAACG,IAAI,CAACT,WAAW,CAACK,oBAAoB,CAAC;IAC/CC,2BAAQ,CAACI,MAAM,CAACC,GAAG,CAAC;MAClBV,IAAI,GAAAM,kBAAA,GAAEP,WAAW,CAACC,IAAI,cAAAM,kBAAA,uBAAhBA,kBAAA,CAAkBL,KAAK;MAC7BE,SAAS,GAAAI,sBAAA,GAAER,WAAW,CAACG,YAAY,cAAAK,sBAAA,uBAAxBA,sBAAA,CAA0BJ;IACvC,CAAC,CAAC;IACFE,2BAAQ,CAACM,QAAQ,CAACd,WAAW,CAAC;EAChC,CAAC,MAAM;IACL;AACJ;AACA;AACA;IACIQ,2BAAQ,CAACG,IAAI,CAAC,YAAY,CAAC;EAC7B;AACF"}
1
+ {"version":3,"file":"mixpanel.js","names":["_mixpanelBrowser","_interopRequireDefault","require","initializeMixpanel","skip","_globalProps$user","_globalProps$organiza","analyticsId","concat","globalProps","user","email","organization","subdomain","mixpanelProjectToken","mixpanel","_globalProps$user2","_globalProps$user3","_globalProps$user4","_globalProps$organiza2","init","people","set","$first_name","firstName","$last_name","lastName","identify"],"sources":["../../../src/initializers/mixpanel.js"],"sourcesContent":["import mixpanel from \"mixpanel-browser\";\n\nexport default function initializeMixpanel(skip) {\n const analyticsId = `${globalProps.user?.email}-${globalProps.organization?.subdomain}`;\n\n if (globalProps.mixpanelProjectToken && !skip?.mixpanel) {\n mixpanel.init(globalProps.mixpanelProjectToken);\n mixpanel.people.set({\n $first_name: globalProps.user?.firstName,\n $last_name: globalProps.user?.lastName,\n user: globalProps.user?.email,\n subdomain: globalProps.organization?.subdomain,\n });\n mixpanel.identify(analyticsId);\n } else {\n /*\n We need to initialize mixpanel with a bogus token in development and test environment to\n prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.\n */\n mixpanel.init(\"TEST_TOKEN\");\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEe,SAASC,kBAAkBA,CAACC,IAAI,EAAE;EAAA,IAAAC,iBAAA,EAAAC,qBAAA;EAC/C,IAAMC,WAAW,MAAAC,MAAA,EAAAH,iBAAA,GAAMI,WAAW,CAACC,IAAI,cAAAL,iBAAA,uBAAhBA,iBAAA,CAAkBM,KAAK,OAAAH,MAAA,EAAAF,qBAAA,GAAIG,WAAW,CAACG,YAAY,cAAAN,qBAAA,uBAAxBA,qBAAA,CAA0BO,SAAS,CAAE;EAEvF,IAAIJ,WAAW,CAACK,oBAAoB,IAAI,EAACV,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEW,QAAQ,GAAE;IAAA,IAAAC,kBAAA,EAAAC,kBAAA,EAAAC,kBAAA,EAAAC,sBAAA;IACvDJ,2BAAQ,CAACK,IAAI,CAACX,WAAW,CAACK,oBAAoB,CAAC;IAC/CC,2BAAQ,CAACM,MAAM,CAACC,GAAG,CAAC;MAClBC,WAAW,GAAAP,kBAAA,GAAEP,WAAW,CAACC,IAAI,cAAAM,kBAAA,uBAAhBA,kBAAA,CAAkBQ,SAAS;MACxCC,UAAU,GAAAR,kBAAA,GAAER,WAAW,CAACC,IAAI,cAAAO,kBAAA,uBAAhBA,kBAAA,CAAkBS,QAAQ;MACtChB,IAAI,GAAAQ,kBAAA,GAAET,WAAW,CAACC,IAAI,cAAAQ,kBAAA,uBAAhBA,kBAAA,CAAkBP,KAAK;MAC7BE,SAAS,GAAAM,sBAAA,GAAEV,WAAW,CAACG,YAAY,cAAAO,sBAAA,uBAAxBA,sBAAA,CAA0BN;IACvC,CAAC,CAAC;IACFE,2BAAQ,CAACY,QAAQ,CAACpB,WAAW,CAAC;EAChC,CAAC,MAAM;IACL;AACJ;AACA;AACA;IACIQ,2BAAQ,CAACK,IAAI,CAAC,YAAY,CAAC;EAC7B;AACF"}
@@ -15,7 +15,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
15
15
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
16
16
  var useFetchNeetoApps = function useFetchNeetoApps(options) {
17
17
  var _globalProps$user;
18
- var scopedQueryKey = ["".concat(_query.QUERY_KEYS.NEETO_APPS_LIST, "-").concat((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.id)];
18
+ var scopedQueryKey = "".concat(_query.QUERY_KEYS.NEETO_APPS_LIST, "-").concat((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.id);
19
19
  var neetoApps = _usePersistedQuery["default"].getCache(scopedQueryKey);
20
20
  return (0, _usePersistedQuery["default"])(scopedQueryKey, _neeto_apps["default"].fetch, _objectSpread({
21
21
  staleTime: _constants.NEETO_APPS_LIST_STALE_TIME,
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchNeetoApps.js","names":["_neetoCist","require","_usePersistedQuery","_interopRequireDefault","_neeto_apps","_constants","_query","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","useFetchNeetoApps","options","_globalProps$user","scopedQueryKey","concat","QUERY_KEYS","NEETO_APPS_LIST","globalProps","user","id","neetoApps","usePersistedQuery","getCache","neetoAppsApi","fetch","staleTime","NEETO_APPS_LIST_STALE_TIME","enabled","isNotPresent","data","_default","exports"],"sources":["../../../../src/react-utils/useFetchNeetoApps/useFetchNeetoApps.js"],"sourcesContent":["import { isNotPresent } from \"neetocist\";\nimport usePersistedQuery from \"react-utils/usePersistedQuery\";\n\nimport neetoAppsApi from \"./apis/neeto_apps\";\n\nimport { NEETO_APPS_LIST_STALE_TIME } from \"../constants\";\nimport { QUERY_KEYS } from \"../constants/query\";\n\nconst useFetchNeetoApps = options => {\n const scopedQueryKey = [\n `${QUERY_KEYS.NEETO_APPS_LIST}-${globalProps.user?.id}`,\n ];\n\n const neetoApps = usePersistedQuery.getCache(scopedQueryKey);\n\n return usePersistedQuery(scopedQueryKey, neetoAppsApi.fetch, {\n staleTime: NEETO_APPS_LIST_STALE_TIME,\n enabled: isNotPresent(neetoApps?.data),\n ...options,\n });\n};\n\nexport default useFetchNeetoApps;\n"],"mappings":";;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAgD,SAAAM,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,aAAAP,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAkB,yBAAA,GAAAlB,MAAA,CAAAmB,gBAAA,CAAAT,MAAA,EAAAV,MAAA,CAAAkB,yBAAA,CAAAJ,MAAA,KAAAlB,OAAA,CAAAI,MAAA,CAAAc,MAAA,GAAAC,OAAA,WAAAC,GAAA,IAAAhB,MAAA,CAAAoB,cAAA,CAAAV,MAAA,EAAAM,GAAA,EAAAhB,MAAA,CAAAK,wBAAA,CAAAS,MAAA,EAAAE,GAAA,iBAAAN,MAAA;AAEhD,IAAMW,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAGC,OAAO,EAAI;EAAA,IAAAC,iBAAA;EACnC,IAAMC,cAAc,GAAG,IAAAC,MAAA,CAClBC,iBAAU,CAACC,eAAe,OAAAF,MAAA,EAAAF,iBAAA,GAAIK,WAAW,CAACC,IAAI,cAAAN,iBAAA,uBAAhBA,iBAAA,CAAkBO,EAAE,EACtD;EAED,IAAMC,SAAS,GAAGC,6BAAiB,CAACC,QAAQ,CAACT,cAAc,CAAC;EAE5D,OAAO,IAAAQ,6BAAiB,EAACR,cAAc,EAAEU,sBAAY,CAACC,KAAK,EAAA1B,aAAA;IACzD2B,SAAS,EAAEC,qCAA0B;IACrCC,OAAO,EAAE,IAAAC,uBAAY,EAACR,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAES,IAAI;EAAC,GACnClB,OAAO,EACV;AACJ,CAAC;AAAC,IAAAmB,QAAA,GAEapB,iBAAiB;AAAAqB,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"useFetchNeetoApps.js","names":["_neetoCist","require","_usePersistedQuery","_interopRequireDefault","_neeto_apps","_constants","_query","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","useFetchNeetoApps","options","_globalProps$user","scopedQueryKey","concat","QUERY_KEYS","NEETO_APPS_LIST","globalProps","user","id","neetoApps","usePersistedQuery","getCache","neetoAppsApi","fetch","staleTime","NEETO_APPS_LIST_STALE_TIME","enabled","isNotPresent","data","_default","exports"],"sources":["../../../../src/react-utils/useFetchNeetoApps/useFetchNeetoApps.js"],"sourcesContent":["import { isNotPresent } from \"neetocist\";\nimport usePersistedQuery from \"react-utils/usePersistedQuery\";\n\nimport neetoAppsApi from \"./apis/neeto_apps\";\n\nimport { NEETO_APPS_LIST_STALE_TIME } from \"../constants\";\nimport { QUERY_KEYS } from \"../constants/query\";\n\nconst useFetchNeetoApps = options => {\n const scopedQueryKey = `${QUERY_KEYS.NEETO_APPS_LIST}-${globalProps.user?.id}`;\n\n const neetoApps = usePersistedQuery.getCache(scopedQueryKey);\n\n return usePersistedQuery(scopedQueryKey, neetoAppsApi.fetch, {\n staleTime: NEETO_APPS_LIST_STALE_TIME,\n enabled: isNotPresent(neetoApps?.data),\n ...options,\n });\n};\n\nexport default useFetchNeetoApps;\n"],"mappings":";;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAD,sBAAA,CAAAF,OAAA;AAEA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAgD,SAAAM,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,aAAAP,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAkB,yBAAA,GAAAlB,MAAA,CAAAmB,gBAAA,CAAAT,MAAA,EAAAV,MAAA,CAAAkB,yBAAA,CAAAJ,MAAA,KAAAlB,OAAA,CAAAI,MAAA,CAAAc,MAAA,GAAAC,OAAA,WAAAC,GAAA,IAAAhB,MAAA,CAAAoB,cAAA,CAAAV,MAAA,EAAAM,GAAA,EAAAhB,MAAA,CAAAK,wBAAA,CAAAS,MAAA,EAAAE,GAAA,iBAAAN,MAAA;AAEhD,IAAMW,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAGC,OAAO,EAAI;EAAA,IAAAC,iBAAA;EACnC,IAAMC,cAAc,MAAAC,MAAA,CAAMC,iBAAU,CAACC,eAAe,OAAAF,MAAA,EAAAF,iBAAA,GAAIK,WAAW,CAACC,IAAI,cAAAN,iBAAA,uBAAhBA,iBAAA,CAAkBO,EAAE,CAAE;EAE9E,IAAMC,SAAS,GAAGC,6BAAiB,CAACC,QAAQ,CAACT,cAAc,CAAC;EAE5D,OAAO,IAAAQ,6BAAiB,EAACR,cAAc,EAAEU,sBAAY,CAACC,KAAK,EAAA1B,aAAA;IACzD2B,SAAS,EAAEC,qCAA0B;IACrCC,OAAO,EAAE,IAAAC,uBAAY,EAACR,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAES,IAAI;EAAC,GACnClB,OAAO,EACV;AACJ,CAAC;AAAC,IAAAmB,QAAA,GAEapB,iBAAiB;AAAAqB,OAAA,cAAAD,QAAA"}
@@ -7,8 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports["default"] = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
- var _reactQuery = require("@tanstack/react-query");
11
- var _ramda = require("ramda");
10
+ var _reactQuery = require("react-query");
12
11
  var _excluded = ["keysToInvalidate"],
13
12
  _excluded2 = ["onSuccess"];
14
13
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -19,22 +18,11 @@ var useMutationWithInvalidation = function useMutationWithInvalidation(mutationF
19
18
  var queryClient = (0, _reactQuery.useQueryClient)();
20
19
  var _onSuccess = options.onSuccess,
21
20
  otherOptions = (0, _objectWithoutProperties2["default"])(options, _excluded2);
22
- return (0, _reactQuery.useMutation)(_objectSpread({
23
- mutationFn: mutationFn,
21
+ return (0, _reactQuery.useMutation)(mutationFn, _objectSpread({
24
22
  onSuccess: function onSuccess(data, variables, context) {
25
23
  keysToInvalidate.forEach(function (key) {
26
- var result = (0, _ramda.type)(key) === "Function" ? key(data, variables, context) : key;
27
- if ((0, _ramda.type)(result) === "Object") {
28
- queryClient.invalidateQueries(result);
29
- } else if ((0, _ramda.type)(result) === "String") {
30
- queryClient.invalidateQueries({
31
- queryKey: [result]
32
- });
33
- } else {
34
- queryClient.invalidateQueries({
35
- queryKey: result
36
- });
37
- }
24
+ var keyToInvalidate = typeof key === "function" ? key(data, variables, context) : key;
25
+ queryClient.invalidateQueries(keyToInvalidate);
38
26
  });
39
27
  _onSuccess === null || _onSuccess === void 0 ? void 0 : _onSuccess(data, variables, context);
40
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useMutationWithInvalidation.js","names":["_reactQuery","require","_ramda","_excluded","_excluded2","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","useMutationWithInvalidation","mutationFn","_ref","keysToInvalidate","options","_objectWithoutProperties2","queryClient","useQueryClient","onSuccess","otherOptions","useMutation","data","variables","context","result","type","invalidateQueries","queryKey","_default","exports"],"sources":["../../../../src/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js"],"sourcesContent":["import { useQueryClient, useMutation } from \"@tanstack/react-query\";\nimport { type } from \"ramda\";\n\nconst useMutationWithInvalidation = (\n mutationFn,\n { keysToInvalidate, ...options }\n) => {\n const queryClient = useQueryClient();\n const { onSuccess, ...otherOptions } = options;\n\n return useMutation({\n mutationFn,\n onSuccess: (data, variables, context) => {\n keysToInvalidate.forEach(key => {\n const result =\n type(key) === \"Function\" ? key(data, variables, context) : key;\n\n if (type(result) === \"Object\") {\n queryClient.invalidateQueries(result);\n } else if (type(result) === \"String\") {\n queryClient.invalidateQueries({ queryKey: [result] });\n } else {\n queryClient.invalidateQueries({ queryKey: result });\n }\n });\n\n onSuccess?.(data, variables, context);\n },\n\n ...otherOptions,\n });\n};\n\nexport default useMutationWithInvalidation;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAA6B,IAAAE,SAAA;EAAAC,UAAA;AAAA,SAAAC,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,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SAAS,EAAEC,OAAO,CAAC,GAAGlB,GAAG;QAEhE,IAAI,IAAAoB,WAAI,EAACD,MAAM,CAAC,KAAK,QAAQ,EAAE;UAC7BR,WAAW,CAACU,iBAAiB,CAACF,MAAM,CAAC;QACvC,CAAC,MAAM,IAAI,IAAAC,WAAI,EAACD,MAAM,CAAC,KAAK,QAAQ,EAAE;UACpCR,WAAW,CAACU,iBAAiB,CAAC;YAAEC,QAAQ,EAAE,CAACH,MAAM;UAAE,CAAC,CAAC;QACvD,CAAC,MAAM;UACLR,WAAW,CAACU,iBAAiB,CAAC;YAAEC,QAAQ,EAAEH;UAAO,CAAC,CAAC;QACrD;MACF,CAAC,CAAC;MAEFN,UAAS,aAATA,UAAS,uBAATA,UAAS,CAAGG,IAAI,EAAEC,SAAS,EAAEC,OAAO,CAAC;IACvC;EAAC,GAEEJ,YAAY,EACf;AACJ,CAAC;AAAC,IAAAS,QAAA,GAEalB,2BAA2B;AAAAmB,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"useMutationWithInvalidation.js","names":["_reactQuery","require","_excluded","_excluded2","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","useMutationWithInvalidation","mutationFn","_ref","keysToInvalidate","options","_objectWithoutProperties2","queryClient","useQueryClient","onSuccess","otherOptions","useMutation","data","variables","context","keyToInvalidate","invalidateQueries","_default","exports"],"sources":["../../../../src/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js"],"sourcesContent":["import { useQueryClient, useMutation } from \"react-query\";\n\nconst useMutationWithInvalidation = (\n mutationFn,\n { keysToInvalidate, ...options }\n) => {\n const queryClient = useQueryClient();\n const { onSuccess, ...otherOptions } = options;\n\n return useMutation(mutationFn, {\n onSuccess: (data, variables, context) => {\n keysToInvalidate.forEach(key => {\n const keyToInvalidate =\n typeof key === \"function\" ? key(data, variables, context) : key;\n queryClient.invalidateQueries(keyToInvalidate);\n });\n onSuccess?.(data, variables, context);\n },\n ...otherOptions,\n });\n};\n\nexport default useMutationWithInvalidation;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAA0D,IAAAC,SAAA;EAAAC,UAAA;AAAA,SAAAC,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,aAAAP,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAkB,yBAAA,GAAAlB,MAAA,CAAAmB,gBAAA,CAAAT,MAAA,EAAAV,MAAA,CAAAkB,yBAAA,CAAAJ,MAAA,KAAAlB,OAAA,CAAAI,MAAA,CAAAc,MAAA,GAAAC,OAAA,WAAAC,GAAA,IAAAhB,MAAA,CAAAoB,cAAA,CAAAV,MAAA,EAAAM,GAAA,EAAAhB,MAAA,CAAAK,wBAAA,CAAAS,MAAA,EAAAE,GAAA,iBAAAN,MAAA;AAE1D,IAAMW,2BAA2B,GAAG,SAA9BA,2BAA2BA,CAC/BC,UAAU,EAAAC,IAAA,EAEP;EAAA,IADDC,gBAAgB,GAAAD,IAAA,CAAhBC,gBAAgB;IAAKC,OAAO,OAAAC,yBAAA,aAAAH,IAAA,EAAA7B,SAAA;EAE9B,IAAMiC,WAAW,GAAG,IAAAC,0BAAc,GAAE;EACpC,IAAQC,UAAS,GAAsBJ,OAAO,CAAtCI,SAAS;IAAKC,YAAY,OAAAJ,yBAAA,aAAKD,OAAO,EAAA9B,UAAA;EAE9C,OAAO,IAAAoC,uBAAW,EAACT,UAAU,EAAAb,aAAA;IAC3BoB,SAAS,EAAE,SAAAA,UAACG,IAAI,EAAEC,SAAS,EAAEC,OAAO,EAAK;MACvCV,gBAAgB,CAACT,OAAO,CAAC,UAAAC,GAAG,EAAI;QAC9B,IAAMmB,eAAe,GACnB,OAAOnB,GAAG,KAAK,UAAU,GAAGA,GAAG,CAACgB,IAAI,EAAEC,SAAS,EAAEC,OAAO,CAAC,GAAGlB,GAAG;QACjEW,WAAW,CAACS,iBAAiB,CAACD,eAAe,CAAC;MAChD,CAAC,CAAC;MACFN,UAAS,aAATA,UAAS,uBAATA,UAAS,CAAGG,IAAI,EAAEC,SAAS,EAAEC,OAAO,CAAC;IACvC;EAAC,GACEJ,YAAY,EACf;AACJ,CAAC;AAAC,IAAAO,QAAA,GAEahB,2BAA2B;AAAAiB,OAAA,cAAAD,QAAA"}
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports["default"] = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = require("react");
10
- var _reactQuery = require("@tanstack/react-query");
11
10
  var _ramda = require("ramda");
11
+ var _reactQuery = require("react-query");
12
12
  var _constants = require("../constants");
13
13
  var _general = require("../../utils/general");
14
14
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -37,10 +37,7 @@ var isOutdated = function isOutdated(localCache, staleTime) {
37
37
  return localCache.modifiedAt <= Date.now() - staleTime;
38
38
  };
39
39
  var usePersistedQuery = function usePersistedQuery(queryKey, fetch, options) {
40
- var queryResult = (0, _reactQuery.useQuery)(_objectSpread({
41
- queryKey: queryKey,
42
- queryFn: fetch
43
- }, options));
40
+ var queryResult = (0, _reactQuery.useQuery)(queryKey, fetch, options);
44
41
  var localCache = localStorageQueryCache.get(queryKey);
45
42
  (0, _react.useEffect)(function () {
46
43
  if (!queryResult.isSuccess) return;
@@ -1 +1 @@
1
- {"version":3,"file":"usePersistedQuery.js","names":["_react","require","_reactQuery","_ramda","_constants","_general","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","localStorageQueryCache","set","data","cache","getAll","newCache","modifiedAt","Date","now","setToLocalStorage","QUERY_CACHE_NAME_SPACE","getFromLocalStorage","get","isOutdated","localCache","staleTime","isNil","usePersistedQuery","queryKey","fetch","options","queryResult","useQuery","queryFn","useEffect","isSuccess","isFreshLoading","isLoading","getCache","_default","exports"],"sources":["../../../../src/react-utils/usePersistedQuery/usePersistedQuery.js"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { isNil } from \"ramda\";\nimport { QUERY_CACHE_NAME_SPACE } from \"react-utils/constants\";\nimport { getFromLocalStorage, setToLocalStorage } from \"utils/general\";\n\nconst localStorageQueryCache = {\n set: (key, data) => {\n const cache = localStorageQueryCache.getAll();\n const newCache = { ...cache, [key]: { data, modifiedAt: Date.now() } };\n setToLocalStorage(QUERY_CACHE_NAME_SPACE, newCache);\n },\n getAll: () => {\n const cache = getFromLocalStorage(QUERY_CACHE_NAME_SPACE);\n if (!cache) return {};\n\n return cache;\n },\n get: key => localStorageQueryCache.getAll()[key],\n};\n\nconst isOutdated = (localCache, staleTime) => {\n if (isNil(localCache)) return true;\n\n if (isNil(staleTime)) return false;\n\n return localCache.modifiedAt <= Date.now() - staleTime;\n};\n\nconst usePersistedQuery = (queryKey, fetch, options) => {\n const queryResult = useQuery({\n queryKey,\n queryFn: fetch,\n ...options,\n });\n const localCache = localStorageQueryCache.get(queryKey);\n\n useEffect(() => {\n if (!queryResult.isSuccess) return;\n localStorageQueryCache.set(queryKey, queryResult.data);\n }, [queryKey, queryResult.data, queryResult.isSuccess]);\n\n if (isOutdated(localCache, options?.staleTime)) {\n return { ...queryResult, isFreshLoading: queryResult.isLoading };\n }\n\n return {\n ...queryResult,\n data: queryResult.data || localCache.data,\n isFreshLoading: false,\n };\n};\n\nusePersistedQuery.getCache = localStorageQueryCache.get;\n\nexport default usePersistedQuery;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAuE,SAAAK,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,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G;AAAC,IAAAiB,QAAA,GAEzCZ,iBAAiB;AAAAa,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"usePersistedQuery.js","names":["_react","require","_ramda","_reactQuery","_constants","_general","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","getOwnPropertyDescriptors","defineProperties","defineProperty","localStorageQueryCache","set","data","cache","getAll","newCache","modifiedAt","Date","now","setToLocalStorage","QUERY_CACHE_NAME_SPACE","getFromLocalStorage","get","isOutdated","localCache","staleTime","isNil","usePersistedQuery","queryKey","fetch","options","queryResult","useQuery","useEffect","isSuccess","isFreshLoading","isLoading","getCache","_default","exports"],"sources":["../../../../src/react-utils/usePersistedQuery/usePersistedQuery.js"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { isNil } from \"ramda\";\nimport { useQuery } from \"react-query\";\nimport { QUERY_CACHE_NAME_SPACE } from \"react-utils/constants\";\nimport { getFromLocalStorage, setToLocalStorage } from \"utils/general\";\n\nconst localStorageQueryCache = {\n set: (key, data) => {\n const cache = localStorageQueryCache.getAll();\n const newCache = { ...cache, [key]: { data, modifiedAt: Date.now() } };\n setToLocalStorage(QUERY_CACHE_NAME_SPACE, newCache);\n },\n getAll: () => {\n const cache = getFromLocalStorage(QUERY_CACHE_NAME_SPACE);\n if (!cache) return {};\n\n return cache;\n },\n get: key => localStorageQueryCache.getAll()[key],\n};\n\nconst isOutdated = (localCache, staleTime) => {\n if (isNil(localCache)) return true;\n\n if (isNil(staleTime)) return false;\n\n return localCache.modifiedAt <= Date.now() - staleTime;\n};\n\nconst usePersistedQuery = (queryKey, fetch, options) => {\n const queryResult = useQuery(queryKey, fetch, options);\n const localCache = localStorageQueryCache.get(queryKey);\n\n useEffect(() => {\n if (!queryResult.isSuccess) return;\n localStorageQueryCache.set(queryKey, queryResult.data);\n }, [queryKey, queryResult.data, queryResult.isSuccess]);\n\n if (isOutdated(localCache, options?.staleTime)) {\n return { ...queryResult, isFreshLoading: queryResult.isLoading };\n }\n\n return {\n ...queryResult,\n data: queryResult.data || localCache.data,\n isFreshLoading: false,\n };\n};\n\nusePersistedQuery.getCache = localStorageQueryCache.get;\n\nexport default usePersistedQuery;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAAuE,SAAAK,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,aAAAP,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAkB,yBAAA,GAAAlB,MAAA,CAAAmB,gBAAA,CAAAT,MAAA,EAAAV,MAAA,CAAAkB,yBAAA,CAAAJ,MAAA,KAAAlB,OAAA,CAAAI,MAAA,CAAAc,MAAA,GAAAC,OA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BAAQ,EAACJ,QAAQ,EAAEC,KAAK,EAAEC,OAAO,CAAC;EACtD,IAAMN,UAAU,GAAGd,sBAAsB,CAACY,GAAG,CAACM,QAAQ,CAAC;EAEvD,IAAAK,gBAAS,EAAC,YAAM;IACd,IAAI,CAACF,WAAW,CAACG,SAAS,EAAE;IAC5BxB,sBAAsB,CAACC,GAAG,CAACiB,QAAQ,EAAEG,WAAW,CAACnB,IAAI,CAAC;EACxD,CAAC,EAAE,CAACgB,QAAQ,EAAEG,WAAW,CAACnB,IAAI,EAAEmB,WAAW,CAACG,SAAS,CAAC,CAAC;EAEvD,IAAIX,UAAU,CAACC,UAAU,EAAEM,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEL,SAAS,CAAC,EAAE;IAC9C,OAAA3B,aAAA,CAAAA,aAAA,KAAYiC,WAAW;MAAEI,cAAc,EAAEJ,WAAW,CAACK;IAAS;EAChE;EAEA,OAAAtC,aAAA,CAAAA,aAAA,KACKiC,WAAW;IACdnB,IAAI,EAAEmB,WAAW,CAACnB,IAAI,IAAIY,UAAU,CAACZ,IAAI;IACzCuB,cAAc,EAAE;EAAK;AAEzB,CAAC;AAEDR,iBAAiB,CAACU,QAAQ,GAAG3B,sBAAsB,CAACY,GAAG;AAAC,IAAAgB,QAAA,GAEzCX,iBAAiB;AAAAY,OAAA,cAAAD,QAAA"}
package/configs/babel.js CHANGED
@@ -1,3 +1,5 @@
1
+ const { TRANSFORM_RULES } = require("./constants");
2
+
1
3
  // eslint-disable-next-line @bigbinary/neeto/no-dangling-constants
2
4
  const VALID_ENVIRONMENTS = ["development", "test", "production"];
3
5
 
@@ -48,35 +50,7 @@ module.exports = function (api) {
48
50
  "babel-plugin-transform-react-remove-prop-types",
49
51
  { removeImport: true },
50
52
  ],
51
- [
52
- "transform-imports",
53
- {
54
- "@bigbinary/neetoui": {
55
- transform: "@bigbinary/neetoui/${member}",
56
- preventFullImport: true,
57
- },
58
- neetoui: {
59
- transform: "neetoui/${member}",
60
- preventFullImport: true,
61
- },
62
- "@bigbinary/neetoui/formik": {
63
- transform: "@bigbinary/neetoui/formik/${member}",
64
- preventFullImport: true,
65
- },
66
- "neetoui/formik": {
67
- transform: "neetoui/formik/${member}",
68
- preventFullImport: true,
69
- },
70
- "@bigbinary/neeto-thank-you-frontend": {
71
- transform: "@bigbinary/neeto-thank-you-frontend/${member}",
72
- preventFullImport: true,
73
- },
74
- neetothankyou: {
75
- transform: "neetothankyou/${member}",
76
- preventFullImport: true,
77
- },
78
- },
79
- ],
53
+ ...TRANSFORM_RULES,
80
54
  ].filter(Boolean),
81
55
  };
82
56
  };
@@ -0,0 +1,120 @@
1
+ const TRANSFORM_RULES = [
2
+ [
3
+ "transform-imports",
4
+ {
5
+ // neetoui
6
+ "@bigbinary/neetoui": {
7
+ transform: "@bigbinary/neetoui/${member}",
8
+ preventFullImport: true,
9
+ },
10
+ neetoui: {
11
+ transform: "neetoui/${member}",
12
+ preventFullImport: true,
13
+ },
14
+ "@bigbinary/neetoui/formik": {
15
+ transform: "@bigbinary/neetoui/formik/${member}",
16
+ preventFullImport: true,
17
+ },
18
+ "neetoui/formik": {
19
+ transform: "neetoui/formik/${member}",
20
+ preventFullImport: true,
21
+ },
22
+
23
+ // neeto-thank-you-frontend
24
+ "@bigbinary/neeto-thank-you-frontend": {
25
+ transform: "@bigbinary/neeto-thank-you-frontend/${member}",
26
+ preventFullImport: true,
27
+ },
28
+ neetothankyou: {
29
+ transform: "neetothankyou/${member}",
30
+ preventFullImport: true,
31
+ },
32
+
33
+ // neeto-payments-frontend
34
+ "@bigbinary/neeto-payments-frontend": {
35
+ transform: "@bigbinary/neeto-payments-frontend/${member}",
36
+ preventFullImport: true,
37
+ },
38
+ neetopayments: {
39
+ transform: "neetopayments/${member}",
40
+ preventFullImport: true,
41
+ },
42
+
43
+ // neeto-editor
44
+ "@bigbinary/neeto-editor": {
45
+ transform: importName => {
46
+ if (/^[A-Z][a-zA-Z]+$/.test(importName)) {
47
+ return `@bigbinary/neeto-editor/${importName}`;
48
+ }
49
+
50
+ return "@bigbinary/neeto-editor/utils";
51
+ },
52
+ preventFullImport: true,
53
+ skipDefaultConversion: true,
54
+ },
55
+ neetoeditor: {
56
+ transform: importName => {
57
+ if (/^[A-Z][a-zA-Z]+$/.test(importName)) {
58
+ return `neetoeditor/${importName}`;
59
+ }
60
+
61
+ return "neetoeditor/utils";
62
+ },
63
+ preventFullImport: true,
64
+ skipDefaultConversion: true,
65
+ },
66
+ "neetoeditor/([A-Z][a-zA-Z]+)$": {
67
+ transform: "neetoeditor/${member}",
68
+ preventFullImport: false,
69
+ },
70
+ "@bigbinary/neeto-editor/([A-Z][a-zA-Z]+)$": {
71
+ transform: "@bigbinary/neeto-editor/${member}",
72
+ preventFullImport: false,
73
+ },
74
+
75
+ // neeto-icons
76
+ "@bigbinary/neeto-icons": {
77
+ transform: "@bigbinary/neeto-icons/${member}",
78
+ preventFullImport: false,
79
+ },
80
+ neetoicons: {
81
+ transform: "neetoicons/${member}",
82
+ preventFullImport: false,
83
+ },
84
+ "@bigbinary/neeto-icons/typeface-logos": {
85
+ transform: "@bigbinary/neeto-icons/typeface-logos/${member}",
86
+ preventFullImport: false,
87
+ },
88
+ "neetoicons/typeface-logos": {
89
+ transform: "neetoicons/typeface-logos/${member}",
90
+ preventFullImport: false,
91
+ },
92
+ "@bigbinary/neeto-icons/app-icons": {
93
+ transform: "@bigbinary/neeto-icons/app-icons/${member}",
94
+ preventFullImport: false,
95
+ },
96
+ "neetoicons/app-icons": {
97
+ transform: "neetoicons/app-icons/${member}",
98
+ preventFullImport: false,
99
+ },
100
+ "@bigbinary/neeto-icons/neeto-logos": {
101
+ transform: "@bigbinary/neeto-icons/neeto-logos/${member}",
102
+ preventFullImport: false,
103
+ },
104
+ "neetoicons/neeto-logos": {
105
+ transform: "neetoicons/neeto-logos/${member}",
106
+ preventFullImport: false,
107
+ },
108
+ "@bigbinary/neeto-icons/misc": {
109
+ transform: "@bigbinary/neeto-icons/misc/${member}",
110
+ preventFullImport: false,
111
+ },
112
+ "neetoicons/misc": {
113
+ transform: "neetoicons/misc/${member}",
114
+ preventFullImport: false,
115
+ },
116
+ },
117
+ ],
118
+ ];
119
+
120
+ module.exports = { TRANSFORM_RULES };
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _typeof from "@babel/runtime/helpers/typeof";
3
3
  import axios from "axios";
4
4
  import i18next from "i18next";
5
- import { keysToCamelCase, matches, serializeKeysToSnakeCase } from "@bigbinary/neeto-cist";
5
+ import { isNotEmpty, keysToCamelCase, matches, serializeKeysToSnakeCase } from "@bigbinary/neeto-cist";
6
6
  import Toastr from "@bigbinary/neetoui/Toastr";
7
7
  import { evolve, omit } from "ramda";
8
8
  import { toast } from "react-toastify";
@@ -15,7 +15,7 @@ var shouldNot = function shouldNot(skip) {
15
15
  return _typeof(skip) === "object" || !skip;
16
16
  };
17
17
  var shouldShowToastr = function shouldShowToastr(response) {
18
- return typeof response === "string" || _typeof(response) === "object" && ((response === null || response === void 0 ? void 0 : response.notice) || (response === null || response === void 0 ? void 0 : response.noticeCode));
18
+ return typeof response === "string" && isNotEmpty(response) || _typeof(response) === "object" && ((response === null || response === void 0 ? void 0 : response.notice) || (response === null || response === void 0 ? void 0 : response.noticeCode));
19
19
  };
20
20
  var setAuthHeaders = function setAuthHeaders() {
21
21
  var _document$querySelect, _axios$defaults$heade;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["axios","i18next","keysToCamelCase","matches","serializeKeysToSnakeCase","Toastr","evolve","omit","toast","useErrorDisplayStore","resetAuthTokens","setParamsSerializer","HEADERS_KEYS","MAXIMUM_OFFLINE_DURATION","checkOnlineInterval","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$show","showToastr","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","concat","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","t","dismissToastInterval","setInterval","dismiss","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref4","message","code","includes","isCancel","globalProps","railsEnv","getUrlPathName","url","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 { keysToCamelCase, matches, serializeKeysToSnakeCase } from \"neetocist\";\nimport { Toastr } from \"neetoui\";\nimport { 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;\n\nconst shouldNot = skip => typeof skip === \"object\" || !skip;\n\nconst shouldShowToastr = response =>\n typeof response === \"string\" ||\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 { showToastr = true } = response.config;\n if (!showToastr) return response;\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 (isOnline()) {\n Toastr.error(i18next.t(\"generic.error\"));\n\n return error;\n }\n\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 { showToastr = true } = error.config ?? {};\n if (!showToastr) return error;\n\n const { status } = error.response ?? {};\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n if (![403, 404, 520].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 Toastr.error(error);\n }\n\n if (status === 520) {\n if (globalProps.railsEnv === \"production\") {\n Toastr.error(i18next.t(\"generic.error\"));\n } else Toastr.error(error);\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?.paramsS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AChI,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEiI,WAAW,GAAE3H,cAAc,EAAE;EAExC,IAAI,EAACN,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEkI,gBAAgB,GAAEvI,mBAAmB,EAAE;EAElD,IAAII,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE6C,YAAY,CAAC,EAAEiF,kBAAkB,CAAC9H,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE6C,YAAY,CAAC;AAC3E"}
1
+ {"version":3,"file":"index.js","names":["axios","i18next","isNotEmpty","keysToCamelCase","matches","serializeKeysToSnakeCase","Toastr","evolve","omit","toast","useErrorDisplayStore","resetAuthTokens","setParamsSerializer","HEADERS_KEYS","MAXIMUM_OFFLINE_DURATION","checkOnlineInterval","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$show","showToastr","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","concat","encodeURIComponent","href","isOnline","navigator","onLine","showOfflineToastr","toastId","t","dismissToastInterval","setInterval","dismiss","clearInterval","handleNetworkError","startTime","Date","now","elapsedTime","showErrorToastr","_error$config3","_error$response3","_ref3","_ref3$showToastr","_ref4","message","code","includes","isCancel","globalProps","railsEnv","getUrlPathName","url","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 { 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;\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 { showToastr = true } = response.config;\n if (!showToastr) return response;\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 (isOnline()) {\n Toastr.error(i18next.t(\"generic.error\"));\n\n return error;\n }\n\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 { showToastr = true } = error.config ?? {};\n if (!showToastr) return error;\n\n const { status } = error.response ?? {};\n\n if (error.message === \"Network Error\") return handleNetworkError(error);\n\n if (error.code === \"ECONNABORTED\") {\n return error;\n }\n\n if (![403, 404, 520].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 Toastr.error(error);\n }\n\n if (status === 520) {\n if (globalProps.railsEnv === \"production\") {\n Toastr.error(i18next.t(\"generic.error\"));\n } else Toastr.error(error);\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,IAAI,QAAQ,OAAO;AACpC,SAASC,KAAK,QAAQ,gBAAgB;AACtC,SAASC,oBAAoB;AAC7B,SAASC,eAAe;AAExB,OAAOC,mBAAmB;AAE1B,SAASC,YAAY,EAAEC,wBAAwB;AAE/C,IAAIC,mBAAmB,GAAG,IAAI;AAE9B,IAAMC,SAAS,GAAG,SAAZA,SAASA,CAAGC,IAAI;EAAA,OAAIC,OAAA,CA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AG,SAA1BA,uBAAuBA,CAAG7H,IAAI,EAAI;EACtCjB,KAAK,CAAC8D,YAAY,CAAC1C,QAAQ,CAACyH,GAAG,CAC7BhF,2BAA2B,CAAC5C,IAAI,CAAC,EACjC+G,yBAAyB,CAAC/G,IAAI,CAAC,CAChC;AACH,CAAC;AAED,IAAM8H,kBAAkB,GAAG,SAArBA,kBAAkBA,CAAG9H,IAAI,EAAI;EACjC,IAAID,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEwG,OAAO,CAAC,EAAEkB,sBAAsB,CAAC1H,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEwG,OAAO,CAAC;EAEnE,IAAIzG,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,QAAQ,CAAC,EAAE0H,uBAAuB,CAAC7H,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEG,QAAQ,CAAC;AACxE,CAAC;AAED,eAAe,SAAS4H,eAAeA,CAAC/H,IAAI,EAAE;EAC5C,IAAI,EAACA,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEgI,OAAO,GAAEjJ,KAAK,CAAC0B,QAAQ,CAACuH,OAAO,GAAG,GAAG;EAEhD,IAAI,EAAChI,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEiI,WAAW,GAAE3H,cAAc,EAAE;EAExC,IAAI,EAACN,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEkI,gBAAgB,GAAEvI,mBAAmB,EAAE;EAElD,IAAII,SAAS,CAACC,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE6C,YAAY,CAAC,EAAEiF,kBAAkB,CAAC9H,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAE6C,YAAY,CAAC;AAC3E"}
@@ -3,10 +3,12 @@ export default function initializeMixpanel(skip) {
3
3
  var _globalProps$user, _globalProps$organiza;
4
4
  var analyticsId = "".concat((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email, "-").concat((_globalProps$organiza = globalProps.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.subdomain);
5
5
  if (globalProps.mixpanelProjectToken && !(skip !== null && skip !== void 0 && skip.mixpanel)) {
6
- var _globalProps$user2, _globalProps$organiza2;
6
+ var _globalProps$user2, _globalProps$user3, _globalProps$user4, _globalProps$organiza2;
7
7
  mixpanel.init(globalProps.mixpanelProjectToken);
8
8
  mixpanel.people.set({
9
- user: (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.email,
9
+ $first_name: (_globalProps$user2 = globalProps.user) === null || _globalProps$user2 === void 0 ? void 0 : _globalProps$user2.firstName,
10
+ $last_name: (_globalProps$user3 = globalProps.user) === null || _globalProps$user3 === void 0 ? void 0 : _globalProps$user3.lastName,
11
+ user: (_globalProps$user4 = globalProps.user) === null || _globalProps$user4 === void 0 ? void 0 : _globalProps$user4.email,
10
12
  subdomain: (_globalProps$organiza2 = globalProps.organization) === null || _globalProps$organiza2 === void 0 ? void 0 : _globalProps$organiza2.subdomain
11
13
  });
12
14
  mixpanel.identify(analyticsId);
@@ -1 +1 @@
1
- {"version":3,"file":"mixpanel.js","names":["mixpanel","initializeMixpanel","skip","_globalProps$user","_globalProps$organiza","analyticsId","concat","globalProps","user","email","organization","subdomain","mixpanelProjectToken","_globalProps$user2","_globalProps$organiza2","init","people","set","identify"],"sources":["../../src/initializers/mixpanel.js"],"sourcesContent":["import mixpanel from \"mixpanel-browser\";\n\nexport default function initializeMixpanel(skip) {\n const analyticsId = `${globalProps.user?.email}-${globalProps.organization?.subdomain}`;\n\n if (globalProps.mixpanelProjectToken && !skip?.mixpanel) {\n mixpanel.init(globalProps.mixpanelProjectToken);\n mixpanel.people.set({\n user: globalProps.user?.email,\n subdomain: globalProps.organization?.subdomain,\n });\n mixpanel.identify(analyticsId);\n } else {\n /*\n We need to initialize mixpanel with a bogus token in development and test environment to\n prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.\n */\n mixpanel.init(\"TEST_TOKEN\");\n }\n}\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,kBAAkB;AAEvC,eAAe,SAASC,kBAAkBA,CAACC,IAAI,EAAE;EAAA,IAAAC,iBAAA,EAAAC,qBAAA;EAC/C,IAAMC,WAAW,MAAAC,MAAA,EAAAH,iBAAA,GAAMI,WAAW,CAACC,IAAI,cAAAL,iBAAA,uBAAhBA,iBAAA,CAAkBM,KAAK,OAAAH,MAAA,EAAAF,qBAAA,GAAIG,WAAW,CAACG,YAAY,cAAAN,qBAAA,uBAAxBA,qBAAA,CAA0BO,SAAS,CAAE;EAEvF,IAAIJ,WAAW,CAACK,oBAAoB,IAAI,EAACV,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEF,QAAQ,GAAE;IAAA,IAAAa,kBAAA,EAAAC,sBAAA;IACvDd,QAAQ,CAACe,IAAI,CAACR,WAAW,CAACK,oBAAoB,CAAC;IAC/CZ,QAAQ,CAACgB,MAAM,CAACC,GAAG,CAAC;MAClBT,IAAI,GAAAK,kBAAA,GAAEN,WAAW,CAACC,IAAI,cAAAK,kBAAA,uBAAhBA,kBAAA,CAAkBJ,KAAK;MAC7BE,SAAS,GAAAG,sBAAA,GAAEP,WAAW,CAACG,YAAY,cAAAI,sBAAA,uBAAxBA,sBAAA,CAA0BH;IACvC,CAAC,CAAC;IACFX,QAAQ,CAACkB,QAAQ,CAACb,WAAW,CAAC;EAChC,CAAC,MAAM;IACL;AACJ;AACA;AACA;IACIL,QAAQ,CAACe,IAAI,CAAC,YAAY,CAAC;EAC7B;AACF"}
1
+ {"version":3,"file":"mixpanel.js","names":["mixpanel","initializeMixpanel","skip","_globalProps$user","_globalProps$organiza","analyticsId","concat","globalProps","user","email","organization","subdomain","mixpanelProjectToken","_globalProps$user2","_globalProps$user3","_globalProps$user4","_globalProps$organiza2","init","people","set","$first_name","firstName","$last_name","lastName","identify"],"sources":["../../src/initializers/mixpanel.js"],"sourcesContent":["import mixpanel from \"mixpanel-browser\";\n\nexport default function initializeMixpanel(skip) {\n const analyticsId = `${globalProps.user?.email}-${globalProps.organization?.subdomain}`;\n\n if (globalProps.mixpanelProjectToken && !skip?.mixpanel) {\n mixpanel.init(globalProps.mixpanelProjectToken);\n mixpanel.people.set({\n $first_name: globalProps.user?.firstName,\n $last_name: globalProps.user?.lastName,\n user: globalProps.user?.email,\n subdomain: globalProps.organization?.subdomain,\n });\n mixpanel.identify(analyticsId);\n } else {\n /*\n We need to initialize mixpanel with a bogus token in development and test environment to\n prevent mixpanel library from throwing an error when we use mixpanel.track() method in react components.\n */\n mixpanel.init(\"TEST_TOKEN\");\n }\n}\n"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,kBAAkB;AAEvC,eAAe,SAASC,kBAAkBA,CAACC,IAAI,EAAE;EAAA,IAAAC,iBAAA,EAAAC,qBAAA;EAC/C,IAAMC,WAAW,MAAAC,MAAA,EAAAH,iBAAA,GAAMI,WAAW,CAACC,IAAI,cAAAL,iBAAA,uBAAhBA,iBAAA,CAAkBM,KAAK,OAAAH,MAAA,EAAAF,qBAAA,GAAIG,WAAW,CAACG,YAAY,cAAAN,qBAAA,uBAAxBA,qBAAA,CAA0BO,SAAS,CAAE;EAEvF,IAAIJ,WAAW,CAACK,oBAAoB,IAAI,EAACV,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEF,QAAQ,GAAE;IAAA,IAAAa,kBAAA,EAAAC,kBAAA,EAAAC,kBAAA,EAAAC,sBAAA;IACvDhB,QAAQ,CAACiB,IAAI,CAACV,WAAW,CAACK,oBAAoB,CAAC;IAC/CZ,QAAQ,CAACkB,MAAM,CAACC,GAAG,CAAC;MAClBC,WAAW,GAAAP,kBAAA,GAAEN,WAAW,CAACC,IAAI,cAAAK,kBAAA,uBAAhBA,kBAAA,CAAkBQ,SAAS;MACxCC,UAAU,GAAAR,kBAAA,GAAEP,WAAW,CAACC,IAAI,cAAAM,kBAAA,uBAAhBA,kBAAA,CAAkBS,QAAQ;MACtCf,IAAI,GAAAO,kBAAA,GAAER,WAAW,CAACC,IAAI,cAAAO,kBAAA,uBAAhBA,kBAAA,CAAkBN,KAAK;MAC7BE,SAAS,GAAAK,sBAAA,GAAET,WAAW,CAACG,YAAY,cAAAM,sBAAA,uBAAxBA,sBAAA,CAA0BL;IACvC,CAAC,CAAC;IACFX,QAAQ,CAACwB,QAAQ,CAACnB,WAAW,CAAC;EAChC,CAAC,MAAM;IACL;AACJ;AACA;AACA;IACIL,QAAQ,CAACiB,IAAI,CAAC,YAAY,CAAC;EAC7B;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "3.6.0-beta3",
3
+ "version": "3.6.0",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
@@ -81,7 +81,6 @@
81
81
  "@faker-js/faker": "^8.2.0",
82
82
  "@honeybadger-io/js": "^6.4.1",
83
83
  "@honeybadger-io/react": "^6.1.3",
84
- "@tanstack/react-query": "5.40.0",
85
84
  "antd": "4.18.7",
86
85
  "autoprefixer": "^10.4.13",
87
86
  "axios": "1.6.2",
@@ -96,6 +95,7 @@
96
95
  "react": "18.2.0",
97
96
  "react-helmet": "^6.1.0",
98
97
  "react-i18next": "^12.3.1",
98
+ "react-query": "^3.39.2",
99
99
  "react-router-dom": "5.3.3",
100
100
  "react-toastify": "8.0.2",
101
101
  "shakapacker": "^6.5.5",
@@ -103,4 +103,4 @@
103
103
  "webpack": "^5.75.0",
104
104
  "yup": "^1.3.3"
105
105
  }
106
- }
106
+ }
@@ -8,7 +8,7 @@ import { NEETO_APPS_LIST_STALE_TIME } from "../constants";
8
8
  import { QUERY_KEYS } from "../constants/query";
9
9
  var useFetchNeetoApps = function useFetchNeetoApps(options) {
10
10
  var _globalProps$user;
11
- var scopedQueryKey = ["".concat(QUERY_KEYS.NEETO_APPS_LIST, "-").concat((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.id)];
11
+ var scopedQueryKey = "".concat(QUERY_KEYS.NEETO_APPS_LIST, "-").concat((_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.id);
12
12
  var neetoApps = usePersistedQuery.getCache(scopedQueryKey);
13
13
  return usePersistedQuery(scopedQueryKey, neetoAppsApi.fetch, _objectSpread({
14
14
  staleTime: NEETO_APPS_LIST_STALE_TIME,
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchNeetoApps.js","names":["isNotPresent","usePersistedQuery","neetoAppsApi","NEETO_APPS_LIST_STALE_TIME","QUERY_KEYS","useFetchNeetoApps","options","_globalProps$user","scopedQueryKey","concat","NEETO_APPS_LIST","globalProps","user","id","neetoApps","getCache","fetch","_objectSpread","staleTime","enabled","data"],"sources":["../../../src/react-utils/useFetchNeetoApps/useFetchNeetoApps.js"],"sourcesContent":["import { isNotPresent } from \"neetocist\";\nimport usePersistedQuery from \"react-utils/usePersistedQuery\";\n\nimport neetoAppsApi from \"./apis/neeto_apps\";\n\nimport { NEETO_APPS_LIST_STALE_TIME } from \"../constants\";\nimport { QUERY_KEYS } from \"../constants/query\";\n\nconst useFetchNeetoApps = options => {\n const scopedQueryKey = [\n `${QUERY_KEYS.NEETO_APPS_LIST}-${globalProps.user?.id}`,\n ];\n\n const neetoApps = usePersistedQuery.getCache(scopedQueryKey);\n\n return usePersistedQuery(scopedQueryKey, neetoAppsApi.fetch, {\n staleTime: NEETO_APPS_LIST_STALE_TIME,\n enabled: isNotPresent(neetoApps?.data),\n ...options,\n });\n};\n\nexport default useFetchNeetoApps;\n"],"mappings":";;;AAAA,SAASA,YAAY;AACrB,OAAOC,iBAAiB;AAExB,OAAOC,YAAY;AAEnB,SAASC,0BAA0B;AACnC,SAASC,UAAU;AAEnB,IAAMC,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAGC,OAAO,EAAI;EAAA,IAAAC,iBAAA;EACnC,IAAMC,cAAc,GAAG,IAAAC,MAAA,CAClBL,UAAU,CAACM,eAAe,OAAAD,MAAA,EAAAF,iBAAA,GAAII,WAAW,CAACC,IAAI,cAAAL,iBAAA,uBAAhBA,iBAAA,CAAkBM,EAAE,EACtD;EAED,IAAMC,SAAS,GAAGb,iBAAiB,CAACc,QAAQ,CAACP,cAAc,CAAC;EAE5D,OAAOP,iBAAiB,CAACO,cAAc,EAAEN,YAAY,CAACc,KAAK,EAAAC,aAAA;IACzDC,SAAS,EAAEf,0BAA0B;IACrCgB,OAAO,EAAEnB,YAAY,CAACc,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEM,IAAI;EAAC,GACnCd,OAAO,EACV;AACJ,CAAC;AAED,eAAeD,iBAAiB"}
1
+ {"version":3,"file":"useFetchNeetoApps.js","names":["isNotPresent","usePersistedQuery","neetoAppsApi","NEETO_APPS_LIST_STALE_TIME","QUERY_KEYS","useFetchNeetoApps","options","_globalProps$user","scopedQueryKey","concat","NEETO_APPS_LIST","globalProps","user","id","neetoApps","getCache","fetch","_objectSpread","staleTime","enabled","data"],"sources":["../../../src/react-utils/useFetchNeetoApps/useFetchNeetoApps.js"],"sourcesContent":["import { isNotPresent } from \"neetocist\";\nimport usePersistedQuery from \"react-utils/usePersistedQuery\";\n\nimport neetoAppsApi from \"./apis/neeto_apps\";\n\nimport { NEETO_APPS_LIST_STALE_TIME } from \"../constants\";\nimport { QUERY_KEYS } from \"../constants/query\";\n\nconst useFetchNeetoApps = options => {\n const scopedQueryKey = `${QUERY_KEYS.NEETO_APPS_LIST}-${globalProps.user?.id}`;\n\n const neetoApps = usePersistedQuery.getCache(scopedQueryKey);\n\n return usePersistedQuery(scopedQueryKey, neetoAppsApi.fetch, {\n staleTime: NEETO_APPS_LIST_STALE_TIME,\n enabled: isNotPresent(neetoApps?.data),\n ...options,\n });\n};\n\nexport default useFetchNeetoApps;\n"],"mappings":";;;AAAA,SAASA,YAAY;AACrB,OAAOC,iBAAiB;AAExB,OAAOC,YAAY;AAEnB,SAASC,0BAA0B;AACnC,SAASC,UAAU;AAEnB,IAAMC,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAGC,OAAO,EAAI;EAAA,IAAAC,iBAAA;EACnC,IAAMC,cAAc,MAAAC,MAAA,CAAML,UAAU,CAACM,eAAe,OAAAD,MAAA,EAAAF,iBAAA,GAAII,WAAW,CAACC,IAAI,cAAAL,iBAAA,uBAAhBA,iBAAA,CAAkBM,EAAE,CAAE;EAE9E,IAAMC,SAAS,GAAGb,iBAAiB,CAACc,QAAQ,CAACP,cAAc,CAAC;EAE5D,OAAOP,iBAAiB,CAACO,cAAc,EAAEN,YAAY,CAACc,KAAK,EAAAC,aAAA;IACzDC,SAAS,EAAEf,0BAA0B;IACrCgB,OAAO,EAAEnB,YAAY,CAACc,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEM,IAAI;EAAC,GACnCd,OAAO,EACV;AACJ,CAAC;AAED,eAAeD,iBAAiB"}
@@ -4,30 +4,18 @@ var _excluded = ["keysToInvalidate"],
4
4
  _excluded2 = ["onSuccess"];
5
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
- import { useQueryClient, useMutation } from "@tanstack/react-query";
8
- import { type } from "ramda";
7
+ import { useQueryClient, useMutation } from "react-query";
9
8
  var useMutationWithInvalidation = function useMutationWithInvalidation(mutationFn, _ref) {
10
9
  var keysToInvalidate = _ref.keysToInvalidate,
11
10
  options = _objectWithoutProperties(_ref, _excluded);
12
11
  var queryClient = useQueryClient();
13
12
  var _onSuccess = options.onSuccess,
14
13
  otherOptions = _objectWithoutProperties(options, _excluded2);
15
- return useMutation(_objectSpread({
16
- mutationFn: mutationFn,
14
+ return useMutation(mutationFn, _objectSpread({
17
15
  onSuccess: function onSuccess(data, variables, context) {
18
16
  keysToInvalidate.forEach(function (key) {
19
- var result = type(key) === "Function" ? key(data, variables, context) : key;
20
- if (type(result) === "Object") {
21
- queryClient.invalidateQueries(result);
22
- } else if (type(result) === "String") {
23
- queryClient.invalidateQueries({
24
- queryKey: [result]
25
- });
26
- } else {
27
- queryClient.invalidateQueries({
28
- queryKey: result
29
- });
30
- }
17
+ var keyToInvalidate = typeof key === "function" ? key(data, variables, context) : key;
18
+ queryClient.invalidateQueries(keyToInvalidate);
31
19
  });
32
20
  _onSuccess === null || _onSuccess === void 0 ? void 0 : _onSuccess(data, variables, context);
33
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useMutationWithInvalidation.js","names":["useQueryClient","useMutation","type","useMutationWithInvalidation","mutationFn","_ref","keysToInvalidate","options","_objectWithoutProperties","_excluded","queryClient","onSuccess","otherOptions","_excluded2","_objectSpread","data","variables","context","forEach","key","result","invalidateQueries","queryKey"],"sources":["../../../src/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js"],"sourcesContent":["import { useQueryClient, useMutation } from \"@tanstack/react-query\";\nimport { type } from \"ramda\";\n\nconst useMutationWithInvalidation = (\n mutationFn,\n { keysToInvalidate, ...options }\n) => {\n const queryClient = useQueryClient();\n const { onSuccess, ...otherOptions } = options;\n\n return useMutation({\n mutationFn,\n onSuccess: (data, variables, context) => {\n keysToInvalidate.forEach(key => {\n const result =\n type(key) === \"Function\" ? key(data, variables, context) : key;\n\n if (type(result) === \"Object\") {\n queryClient.invalidateQueries(result);\n } else if (type(result) === \"String\") {\n queryClient.invalidateQueries({ queryKey: [result] });\n } else {\n queryClient.invalidateQueries({ queryKey: result });\n }\n });\n\n onSuccess?.(data, variables, context);\n },\n\n ...otherOptions,\n });\n};\n\nexport default useMutationWithInvalidation;\n"],"mappings":";;;;;;AAAA,SAASA,cAAc,EAAEC,WAAW,QAAQ,uBAAuB;AACnE,SAASC,IAAI,QAAQ,OAAO;AAE5B,IAAMC,2BAA2B,GAAG,SAA9BA,2BAA2BA,CAC/BC,UAAU,EAAAC,IAAA,EAEP;EAAA,IADDC,gBAAgB,GAAAD,IAAA,CAAhBC,gBAAgB;IAAKC,OAAO,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EAE9B,IAAMC,WAAW,GAAGV,cAAc,EAAE;EACpC,IAAQW,UAAS,GAAsBJ,OAAO,CAAtCI,SAAS;IAAKC,YAAY,GAAAJ,wBAAA,CAAKD,OAAO,EAAAM,UAAA;EAE9C,OAAOZ,WAAW,CAAAa,aAAA;IAChBV,UAAU,EAAVA,UAAU;IACVO,SAAS,EAAE,SAAAA,UAACI,IAAI,EAAEC,SAAS,EAAEC,OAAO,EAAK;MACvCX,gBAAgB,CAACY,OAAO,CAAC,UAAAC,GAAG,EAAI;QAC9B,IAAMC,MAAM,GACVlB,IAAI,CAACiB,GAAG,CAAC,KAAK,UAAU,GAAGA,GAAG,CAACJ,IAAI,EAAEC,SAAS,EAAEC,OAAO,CAAC,GAAGE,GAAG;QAEhE,IAAIjB,IAAI,CAACkB,MAAM,CAAC,KAAK,QAAQ,EAAE;UAC7BV,WAAW,CAACW,iBAAiB,CAACD,MAAM,CAAC;QACvC,CAAC,MAAM,IAAIlB,IAAI,CAACkB,MAAM,CAAC,KAAK,QAAQ,EAAE;UACpCV,WAAW,CAACW,iBAAiB,CAAC;YAAEC,QAAQ,EAAE,CAACF,MAAM;UAAE,CAAC,CAAC;QACvD,CAAC,MAAM;UACLV,WAAW,CAACW,iBAAiB,CAAC;YAAEC,QAAQ,EAAEF;UAAO,CAAC,CAAC;QACrD;MACF,CAAC,CAAC;MAEFT,UAAS,aAATA,UAAS,uBAATA,UAAS,CAAGI,IAAI,EAAEC,SAAS,EAAEC,OAAO,CAAC;IACvC;EAAC,GAEEL,YAAY,EACf;AACJ,CAAC;AAED,eAAeT,2BAA2B"}
1
+ {"version":3,"file":"useMutationWithInvalidation.js","names":["useQueryClient","useMutation","useMutationWithInvalidation","mutationFn","_ref","keysToInvalidate","options","_objectWithoutProperties","_excluded","queryClient","onSuccess","otherOptions","_excluded2","_objectSpread","data","variables","context","forEach","key","keyToInvalidate","invalidateQueries"],"sources":["../../../src/react-utils/useMutationWithInvalidation/useMutationWithInvalidation.js"],"sourcesContent":["import { useQueryClient, useMutation } from \"react-query\";\n\nconst useMutationWithInvalidation = (\n mutationFn,\n { keysToInvalidate, ...options }\n) => {\n const queryClient = useQueryClient();\n const { onSuccess, ...otherOptions } = options;\n\n return useMutation(mutationFn, {\n onSuccess: (data, variables, context) => {\n keysToInvalidate.forEach(key => {\n const keyToInvalidate =\n typeof key === \"function\" ? key(data, variables, context) : key;\n queryClient.invalidateQueries(keyToInvalidate);\n });\n onSuccess?.(data, variables, context);\n },\n ...otherOptions,\n });\n};\n\nexport default useMutationWithInvalidation;\n"],"mappings":";;;;;;AAAA,SAASA,cAAc,EAAEC,WAAW,QAAQ,aAAa;AAEzD,IAAMC,2BAA2B,GAAG,SAA9BA,2BAA2BA,CAC/BC,UAAU,EAAAC,IAAA,EAEP;EAAA,IADDC,gBAAgB,GAAAD,IAAA,CAAhBC,gBAAgB;IAAKC,OAAO,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EAE9B,IAAMC,WAAW,GAAGT,cAAc,EAAE;EACpC,IAAQU,UAAS,GAAsBJ,OAAO,CAAtCI,SAAS;IAAKC,YAAY,GAAAJ,wBAAA,CAAKD,OAAO,EAAAM,UAAA;EAE9C,OAAOX,WAAW,CAACE,UAAU,EAAAU,aAAA;IAC3BH,SAAS,EAAE,SAAAA,UAACI,IAAI,EAAEC,SAAS,EAAEC,OAAO,EAAK;MACvCX,gBAAgB,CAACY,OAAO,CAAC,UAAAC,GAAG,EAAI;QAC9B,IAAMC,eAAe,GACnB,OAAOD,GAAG,KAAK,UAAU,GAAGA,GAAG,CAACJ,IAAI,EAAEC,SAAS,EAAEC,OAAO,CAAC,GAAGE,GAAG;QACjET,WAAW,CAACW,iBAAiB,CAACD,eAAe,CAAC;MAChD,CAAC,CAAC;MACFT,UAAS,aAATA,UAAS,uBAATA,UAAS,CAAGI,IAAI,EAAEC,SAAS,EAAEC,OAAO,CAAC;IACvC;EAAC,GACEL,YAAY,EACf;AACJ,CAAC;AAED,eAAeT,2BAA2B"}
@@ -2,8 +2,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
4
  import { useEffect } from "react";
5
- import { useQuery } from "@tanstack/react-query";
6
5
  import { isNil } from "ramda";
6
+ import { useQuery } from "react-query";
7
7
  import { QUERY_CACHE_NAME_SPACE } from "../constants";
8
8
  import { getFromLocalStorage, setToLocalStorage } from "../../utils/general";
9
9
  var localStorageQueryCache = {
@@ -30,10 +30,7 @@ var isOutdated = function isOutdated(localCache, staleTime) {
30
30
  return localCache.modifiedAt <= Date.now() - staleTime;
31
31
  };
32
32
  var usePersistedQuery = function usePersistedQuery(queryKey, fetch, options) {
33
- var queryResult = useQuery(_objectSpread({
34
- queryKey: queryKey,
35
- queryFn: fetch
36
- }, options));
33
+ var queryResult = useQuery(queryKey, fetch, options);
37
34
  var localCache = localStorageQueryCache.get(queryKey);
38
35
  useEffect(function () {
39
36
  if (!queryResult.isSuccess) return;
@@ -1 +1 @@
1
- {"version":3,"file":"usePersistedQuery.js","names":["useEffect","useQuery","isNil","QUERY_CACHE_NAME_SPACE","getFromLocalStorage","setToLocalStorage","localStorageQueryCache","set","key","data","cache","getAll","newCache","_objectSpread","_defineProperty","modifiedAt","Date","now","get","isOutdated","localCache","staleTime","usePersistedQuery","queryKey","fetch","options","queryResult","queryFn","isSuccess","isFreshLoading","isLoading","getCache"],"sources":["../../../src/react-utils/usePersistedQuery/usePersistedQuery.js"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { isNil } from \"ramda\";\nimport { QUERY_CACHE_NAME_SPACE } from \"react-utils/constants\";\nimport { getFromLocalStorage, setToLocalStorage } from \"utils/general\";\n\nconst localStorageQueryCache = {\n set: (key, data) => {\n const cache = localStorageQueryCache.getAll();\n const newCache = { ...cache, [key]: { data, modifiedAt: Date.now() } };\n setToLocalStorage(QUERY_CACHE_NAME_SPACE, newCache);\n },\n getAll: () => {\n const cache = getFromLocalStorage(QUERY_CACHE_NAME_SPACE);\n if (!cache) return {};\n\n return cache;\n },\n get: key => localStorageQueryCache.getAll()[key],\n};\n\nconst isOutdated = (localCache, staleTime) => {\n if (isNil(localCache)) return true;\n\n if (isNil(staleTime)) return false;\n\n return localCache.modifiedAt <= Date.now() - staleTime;\n};\n\nconst usePersistedQuery = (queryKey, fetch, options) => {\n const queryResult = useQuery({\n queryKey,\n queryFn: fetch,\n ...options,\n });\n const localCache = localStorageQueryCache.get(queryKey);\n\n useEffect(() => {\n if (!queryResult.isSuccess) return;\n localStorageQueryCache.set(queryKey, queryResult.data);\n }, [queryKey, queryResult.data, queryResult.isSuccess]);\n\n if (isOutdated(localCache, options?.staleTime)) {\n return { ...queryResult, isFreshLoading: queryResult.isLoading };\n }\n\n return {\n ...queryResult,\n data: queryResult.data || localCache.data,\n isFreshLoading: false,\n };\n};\n\nusePersistedQuery.getCache = localStorageQueryCache.get;\n\nexport default usePersistedQuery;\n"],"mappings":";;;AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,KAAK,QAAQ,OAAO;AAC7B,SAASC,sBAAsB;AAC/B,SAASC,mBAAmB,EAAEC,iBAAiB;AAE/C,IAAMC,sBAAsB,GAAG;EAC7BC,GAAG,EAAE,SAAAA,IAACC,GAAG,EAAEC,IAAI,EAAK;IAClB,IAAMC,KAAK,GAAGJ,sBAAsB,CAACK,MAAM,EAAE;IAC7C,IAAMC,QAAQ,GAAAC,aAAA,CAAAA,aAAA,KAAQH,KAAK,OAAAI,eAAA,KAAGN,GAAG,EAAG;MAAEC,IAAI,EAAJA,IAAI;MAAEM,UAAU,EAAEC,IAAI,CAACC,GAAG;IAAG,CAAC,EAAE;IACtEZ,iBAAiB,CAACF,sBAAsB,EAAES,QAAQ,CAAC;EACrD,CAAC;EACDD,MAAM,EAAE,SAAAA,OAAA,EAAM;IACZ,IAAMD,KAAK,GAAGN,mBAAmB,CAACD,sBAAsB,CAAC;IACzD,IAAI,CAACO,KAAK,EAAE,OAAO,CAAC,CAAC;IAErB,OAAOA,KAAK;EACd,CAAC;EACDQ,GAAG,EAAE,SAAAA,IAAAV,GAAG;IAAA,OAAIF,sBAAsB,CAACK,MAAM,EAAE,CAACH,GAAG,CAAC;EAAA;AAClD,CAAC;AAED,IAAMW,UAAU,GAAG,SAAbA,UAAUA,CAAIC,UAAU,EAAEC,SAAS,EAAK;EAC5C,IAAInB,KAAK,CAACkB,UAAU,CAAC,EAAE,OAAO,IAAI;EAElC,IAAIlB,KAAK,CAACmB,SAAS,CAAC,EAAE,OAAO,KAAK;EAElC,OAAOD,UAAU,CAACL,UAAU,IAAIC,IAAI,CAACC,GAAG,EAAE,GAAGI,SAAS;AACxD,CAAC;AAED,IAAMC,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAIC,QAAQ,EAAEC,KAAK,EAAEC,OAAO,EAAK;EACtD,IAAMC,WAAW,GAAGzB,QAAQ,CAAAY,aAAA;IAC1BU,QAAQ,EAARA,QAAQ;IACRI,OAAO,EAAEH;EAAK,GACXC,OAAO,EACV;EACF,IAAML,UAAU,GAAGd,sBAAsB,CAACY,GAAG,CAACK,QAAQ,CAAC;EAEvDvB,SAAS,CAAC,YAAM;IACd,IAAI,CAAC0B,WAAW,CAACE,SAAS,EAAE;IAC5BtB,sBAAsB,CAACC,GAAG,CAACgB,QAAQ,EAAEG,WAAW,CAACjB,IAAI,CAAC;EACxD,CAAC,EAAE,CAACc,QAAQ,EAAEG,WAAW,CAACjB,IAAI,EAAEiB,WAAW,CAACE,SAAS,CAAC,CAAC;EAEvD,IAAIT,UAAU,CAACC,UAAU,EAAEK,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEJ,SAAS,CAAC,EAAE;IAC9C,OAAAR,aAAA,CAAAA,aAAA,KAAYa,WAAW;MAAEG,cAAc,EAAEH,WAAW,CAACI;IAAS;EAChE;EAEA,OAAAjB,aAAA,CAAAA,aAAA,KACKa,WAAW;IACdjB,IAAI,EAAEiB,WAAW,CAACjB,IAAI,IAAIW,UAAU,CAACX,IAAI;IACzCoB,cAAc,EAAE;EAAK;AAEzB,CAAC;AAEDP,iBAAiB,CAACS,QAAQ,GAAGzB,sBAAsB,CAACY,GAAG;AAEvD,eAAeI,iBAAiB"}
1
+ {"version":3,"file":"usePersistedQuery.js","names":["useEffect","isNil","useQuery","QUERY_CACHE_NAME_SPACE","getFromLocalStorage","setToLocalStorage","localStorageQueryCache","set","key","data","cache","getAll","newCache","_objectSpread","_defineProperty","modifiedAt","Date","now","get","isOutdated","localCache","staleTime","usePersistedQuery","queryKey","fetch","options","queryResult","isSuccess","isFreshLoading","isLoading","getCache"],"sources":["../../../src/react-utils/usePersistedQuery/usePersistedQuery.js"],"sourcesContent":["import { useEffect } from \"react\";\n\nimport { isNil } from \"ramda\";\nimport { useQuery } from \"react-query\";\nimport { QUERY_CACHE_NAME_SPACE } from \"react-utils/constants\";\nimport { getFromLocalStorage, setToLocalStorage } from \"utils/general\";\n\nconst localStorageQueryCache = {\n set: (key, data) => {\n const cache = localStorageQueryCache.getAll();\n const newCache = { ...cache, [key]: { data, modifiedAt: Date.now() } };\n setToLocalStorage(QUERY_CACHE_NAME_SPACE, newCache);\n },\n getAll: () => {\n const cache = getFromLocalStorage(QUERY_CACHE_NAME_SPACE);\n if (!cache) return {};\n\n return cache;\n },\n get: key => localStorageQueryCache.getAll()[key],\n};\n\nconst isOutdated = (localCache, staleTime) => {\n if (isNil(localCache)) return true;\n\n if (isNil(staleTime)) return false;\n\n return localCache.modifiedAt <= Date.now() - staleTime;\n};\n\nconst usePersistedQuery = (queryKey, fetch, options) => {\n const queryResult = useQuery(queryKey, fetch, options);\n const localCache = localStorageQueryCache.get(queryKey);\n\n useEffect(() => {\n if (!queryResult.isSuccess) return;\n localStorageQueryCache.set(queryKey, queryResult.data);\n }, [queryKey, queryResult.data, queryResult.isSuccess]);\n\n if (isOutdated(localCache, options?.staleTime)) {\n return { ...queryResult, isFreshLoading: queryResult.isLoading };\n }\n\n return {\n ...queryResult,\n data: queryResult.data || localCache.data,\n isFreshLoading: false,\n };\n};\n\nusePersistedQuery.getCache = localStorageQueryCache.get;\n\nexport default usePersistedQuery;\n"],"mappings":";;;AAAA,SAASA,SAAS,QAAQ,OAAO;AAEjC,SAASC,KAAK,QAAQ,OAAO;AAC7B,SAASC,QAAQ,QAAQ,aAAa;AACtC,SAASC,sBAAsB;AAC/B,SAASC,mBAAmB,EAAEC,iBAAiB;AAE/C,IAAMC,sBA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IAC5BrB,sBAAsB,CAACC,GAAG,CAACgB,QAAQ,EAAEG,WAAW,CAACjB,IAAI,CAAC;EACxD,CAAC,EAAE,CAACc,QAAQ,EAAEG,WAAW,CAACjB,IAAI,EAAEiB,WAAW,CAACC,SAAS,CAAC,CAAC;EAEvD,IAAIR,UAAU,CAACC,UAAU,EAAEK,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEJ,SAAS,CAAC,EAAE;IAC9C,OAAAR,aAAA,CAAAA,aAAA,KAAYa,WAAW;MAAEE,cAAc,EAAEF,WAAW,CAACG;IAAS;EAChE;EAEA,OAAAhB,aAAA,CAAAA,aAAA,KACKa,WAAW;IACdjB,IAAI,EAAEiB,WAAW,CAACjB,IAAI,IAAIW,UAAU,CAACX,IAAI;IACzCmB,cAAc,EAAE;EAAK;AAEzB,CAAC;AAEDN,iBAAiB,CAACQ,QAAQ,GAAGxB,sBAAsB,CAACY,GAAG;AAEvD,eAAeI,iBAAiB"}
package/react-utils.d.ts CHANGED
@@ -3,7 +3,7 @@ import { RouteProps } from "react-router-dom";
3
3
  import { Notice } from "@honeybadger-io/js/dist/server/types/core/types";
4
4
  import { History } from "history";
5
5
  import { StoreApi, UseBoundStore } from "zustand";
6
- import { UseQueryOptions, UseQueryResult, UseMutationOptions, UseMutationResult, QueryKey, MutationFunction } from "@tanstack/react-query";
6
+ import { UseQueryOptions, UseQueryResult, UseMutationOptions, UseMutationResult, QueryKey, MutationFunction } from "react-query";
7
7
  import { KeyPrefix, Namespace } from "i18next";
8
8
  import { DefaultNamespace } from "react-i18next/TransWithoutContext";
9
9
  import { qsOptionsType, QueryParamsType } from "./utils";
@@ -1471,9 +1471,7 @@ type QueryKeyOrFilters = QueryKey | QueryFilters;
1471
1471
  * useMutation(questionsApi.update, {
1472
1472
  * ...options,
1473
1473
  * onSuccess: (data, ...args) => {
1474
- * queryClient.invalidateQueries({
1475
- * queryKey: ["QUESTIONS"]
1476
- * });
1474
+ * queryClient.invalidateQueries("QUESTIONS");
1477
1475
  * queryClient.setQueryData(["RESPONSES"], data);
1478
1476
  * options?.onSuccess(data, ...args);
1479
1477
  * },
@@ -1493,9 +1491,7 @@ type QueryKeyOrFilters = QueryKey | QueryFilters;
1493
1491
  * useMutation(questionsApi.update, {
1494
1492
  * ...options,
1495
1493
  * onSuccess: (...args) => {
1496
- * queryClient.invalidateQueries({
1497
- * queryKey: ["FORM", "QUESTIONS"],
1498
- * });
1494
+ * queryClient.invalidateQueries(["FORM", "QUESTIONS"]);
1499
1495
  * options?.onSuccess(...args);
1500
1496
  * },
1501
1497
  * });
@@ -1514,12 +1510,8 @@ type QueryKeyOrFilters = QueryKey | QueryFilters;
1514
1510
  * useMutation(questionsApi.update, {
1515
1511
  * ...options,
1516
1512
  * onSuccess: () => {
1517
- * queryClient.invalidateQueries({
1518
- * queryKey: ["FORM"],
1519
- * });
1520
- * queryClient.invalidateQueries({
1521
- * queryKey: ["QUESTIONS"],
1522
- * });
1513
+ * queryClient.invalidateQueries("FORM");
1514
+ * queryClient.invalidateQueries("QUESTIONS");
1523
1515
  * options?.onSuccess(...args);
1524
1516
  * },
1525
1517
  * });
@@ -1539,15 +1531,13 @@ type QueryKeyOrFilters = QueryKey | QueryFilters;
1539
1531
  * ...options,
1540
1532
  * onSuccess: (...args) => {
1541
1533
  * const [_, { id }] = args;
1542
- * queryClient.invalidateQueries({
1543
- * queryKey: ["QUESTION", id],
1544
- * });
1534
+ * queryClient.invalidateQueries(["QUESTION", id]);
1545
1535
  * options?.onSuccess(...args);
1546
1536
  * },
1547
1537
  * });
1548
1538
  *
1549
1539
  * // Update question component
1550
- * const { mutate: updateQuestions, isPending } = useUpdateQuestions({
1540
+ * const { mutate: updateQuestions, isLoading } = useUpdateQuestions({
1551
1541
  * onError: e => logger.error(e),
1552
1542
  * });
1553
1543
  * @endexample