@onairos/react-native 3.7.2 â 3.7.4
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.
- package/lib/commonjs/api/index.js +219 -9
- package/lib/commonjs/components/BodyText.js +27 -9
- package/lib/commonjs/components/BrandMark.js +111 -10
- package/lib/commonjs/components/CodeInput.js +120 -9
- package/lib/commonjs/components/EmailInput.js +30 -8
- package/lib/commonjs/components/GoogleButton.js +56 -9
- package/lib/commonjs/components/HeadingGroup.js +43 -9
- package/lib/commonjs/components/LLMDataInputModal.js +664 -14
- package/lib/commonjs/components/ModalHeader.js +99 -9
- package/lib/commonjs/components/ModalSheet.js +47 -9
- package/lib/commonjs/components/Onairos.js +380 -14
- package/lib/commonjs/components/OnairosButton.js +313 -13
- package/lib/commonjs/components/OnairosSignInButton.js +130 -12
- package/lib/commonjs/components/Overlay.js +465 -13
- package/lib/commonjs/components/PersonaImage.js +137 -10
- package/lib/commonjs/components/PersonaLoadingScreen.js +318 -12
- package/lib/commonjs/components/PersonalizationConsentScreen.js +467 -13
- package/lib/commonjs/components/PinCreationScreen.js +403 -12
- package/lib/commonjs/components/PinInput.js +464 -9
- package/lib/commonjs/components/PlatformConnectorsStep.js +1311 -23
- package/lib/commonjs/components/PlatformList.js +137 -10
- package/lib/commonjs/components/PlatformToggle.js +180 -9
- package/lib/commonjs/components/PrimaryButton.js +180 -10
- package/lib/commonjs/components/SignInMatchAnimation.js +197 -9
- package/lib/commonjs/components/SignInStep.js +345 -12
- package/lib/commonjs/components/UniversalOnboarding.js +2780 -30
- package/lib/commonjs/components/VerificationStep.js +176 -11
- package/lib/commonjs/components/WelcomeScreen.js +461 -22
- package/lib/commonjs/components/icons/Basicproficon.js +37 -8
- package/lib/commonjs/components/icons/Basicprofile.js +21 -8
- package/lib/commonjs/components/icons/Checkbox.js +21 -8
- package/lib/commonjs/components/icons/Checkmark.js +27 -8
- package/lib/commonjs/components/icons/Contentanalysis.js +21 -8
- package/lib/commonjs/components/icons/Contenticon.js +39 -8
- package/lib/commonjs/components/icons/EnochE.js +41 -8
- package/lib/commonjs/components/icons/Personalityicon.js +30 -8
- package/lib/commonjs/components/icons/Personalityprofile.js +21 -8
- package/lib/commonjs/components/icons/Personalitytraits.js +21 -8
- package/lib/commonjs/components/icons/Userpreferences.js +21 -8
- package/lib/commonjs/components/icons/index.js +84 -17
- package/lib/commonjs/components/onboarding/OAuthWebView.js +1754 -18
- package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -10
- package/lib/commonjs/components/onboarding/PinInput.js +283 -10
- package/lib/commonjs/components/onboarding/PlatformConnector.js +249 -11
- package/lib/commonjs/config/PLATFORM_APIS.md +849 -0
- package/lib/commonjs/config/api.js +56 -7
- package/lib/commonjs/constants/index.js +120 -7
- package/lib/commonjs/context/AuthContext.js +345 -10
- package/lib/commonjs/hooks/useConnectedAccounts.js +111 -9
- package/lib/commonjs/hooks/useConnections.js +102 -8
- package/lib/commonjs/hooks/useCredentials.js +178 -10
- package/lib/commonjs/hooks/useUserConnections.js +148 -10
- package/lib/commonjs/index.js +439 -34
- package/lib/commonjs/services/apiClient.js +298 -8
- package/lib/commonjs/services/biometricPinService.js +180 -8
- package/lib/commonjs/services/chatGPTConversationExtractor.js +155 -8
- package/lib/commonjs/services/chatGPTConversationService.js +275 -9
- package/lib/commonjs/services/claudeConversationExtractor.js +103 -8
- package/lib/commonjs/services/claudeConversationService.js +158 -9
- package/lib/commonjs/services/connectedAccountsService.js +310 -10
- package/lib/commonjs/services/googleAuthService.js +252 -11
- package/lib/commonjs/services/hingeDataExtractor.js +105 -8
- package/lib/commonjs/services/hingeDataService.js +150 -9
- package/lib/commonjs/services/imageCompressionService.js +260 -7
- package/lib/commonjs/services/instagramDataExtractor.js +126 -8
- package/lib/commonjs/services/instagramDataService.js +163 -9
- package/lib/commonjs/services/jwtStorageService.js +276 -7
- package/lib/commonjs/services/linkedinDOMExtractor.js +245 -7
- package/lib/commonjs/services/linkedinProfileService.js +222 -9
- package/lib/commonjs/services/linkedinScrapingService.js +230 -8
- package/lib/commonjs/services/llmDataStorage.js +294 -8
- package/lib/commonjs/services/mobileTrainingService.js +186 -8
- package/lib/commonjs/services/netflixDataExtractor.js +120 -8
- package/lib/commonjs/services/netflixDataService.js +198 -9
- package/lib/commonjs/services/pinEncryptionService.js +84 -8
- package/lib/commonjs/services/pinStorageUtils.js +105 -7
- package/lib/commonjs/services/platformAuthService.js +1484 -12
- package/lib/commonjs/services/sephoraDataExtractor.js +140 -8
- package/lib/commonjs/services/sephoraDataService.js +200 -9
- package/lib/commonjs/services/spotifyDataExtractor.js +148 -8
- package/lib/commonjs/services/spotifyDataService.js +241 -9
- package/lib/commonjs/services/storageService.js +404 -8
- package/lib/commonjs/services/telegramDataExtractor.js +115 -8
- package/lib/commonjs/services/telegramDataService.js +499 -9
- package/lib/commonjs/services/trainingApiHelpers.js +73 -7
- package/lib/commonjs/services/userConnectionsService.js +340 -10
- package/lib/commonjs/services/youtubeMigrationService.js +416 -10
- package/lib/commonjs/theme/index.js +250 -7
- package/lib/commonjs/types/ambient.d.js +2 -1
- package/lib/commonjs/types/declarations.d.js +2 -1
- package/lib/commonjs/types/index.js +6 -1
- package/lib/commonjs/types/node-fix.d.js +2 -1
- package/lib/commonjs/types/node-override.d.js +2 -1
- package/lib/commonjs/types/opacity.d.js +2 -1
- package/lib/commonjs/types.js +14 -1
- package/lib/commonjs/utils/Portal.js +98 -8
- package/lib/commonjs/utils/api.js +130 -9
- package/lib/commonjs/utils/assetRegistry.js +210 -35
- package/lib/commonjs/utils/auth.js +112 -9
- package/lib/commonjs/utils/connectorTests.js +613 -29
- package/lib/commonjs/utils/crypto.js +62 -8
- package/lib/commonjs/utils/debugHelper.js +64 -1
- package/lib/commonjs/utils/encryption.js +76 -7
- package/lib/commonjs/utils/eventUtils.js +288 -1
- package/lib/commonjs/utils/haptics.js +66 -9
- package/lib/commonjs/utils/imagePreloader.js +6 -1
- package/lib/commonjs/utils/networkDiagnostics.js +226 -8
- package/lib/commonjs/utils/onairosApi.js +350 -9
- package/lib/commonjs/utils/programmaticFlow.js +117 -9
- package/lib/commonjs/utils/retryHelper.js +220 -1
- package/lib/commonjs/utils/secureStorage.js +349 -10
- package/lib/commonjs/utils/webviewScripts/chatgpt.js +551 -1
- package/lib/commonjs/utils/webviewScripts/claude.js +376 -1
- package/lib/commonjs/utils/webviewScripts/hinge.js +411 -1
- package/lib/commonjs/utils/webviewScripts/index.js +698 -15
- package/lib/commonjs/utils/webviewScripts/instagram.js +454 -1
- package/lib/commonjs/utils/webviewScripts/linkedin.js +880 -1
- package/lib/commonjs/utils/webviewScripts/netflix.js +382 -1
- package/lib/commonjs/utils/webviewScripts/sephora.js +516 -1
- package/lib/commonjs/utils/webviewScripts/spotify.js +419 -1
- package/lib/commonjs/utils/webviewScripts/telegram.js +678 -1
- package/lib/module/api/index.js +211 -1
- package/lib/module/components/BodyText.js +20 -1
- package/lib/module/components/BrandMark.js +104 -1
- package/lib/module/components/CodeInput.js +113 -1
- package/lib/module/components/EmailInput.js +23 -1
- package/lib/module/components/GoogleButton.js +49 -1
- package/lib/module/components/HeadingGroup.js +36 -1
- package/lib/module/components/LLMDataInputModal.js +656 -7
- package/lib/module/components/ModalHeader.js +92 -1
- package/lib/module/components/ModalSheet.js +39 -1
- package/lib/module/components/Onairos.js +373 -1
- package/lib/module/components/OnairosButton.js +305 -1
- package/lib/module/components/OnairosSignInButton.js +121 -1
- package/lib/module/components/Overlay.js +456 -1
- package/lib/module/components/PersonaImage.js +129 -1
- package/lib/module/components/PersonaLoadingScreen.js +310 -1
- package/lib/module/components/PersonalizationConsentScreen.js +460 -1
- package/lib/module/components/PinCreationScreen.js +396 -1
- package/lib/module/components/PinInput.js +456 -1
- package/lib/module/components/PlatformConnectorsStep.js +1302 -6
- package/lib/module/components/PlatformList.js +129 -1
- package/lib/module/components/PlatformToggle.js +173 -1
- package/lib/module/components/PrimaryButton.js +172 -1
- package/lib/module/components/SignInMatchAnimation.js +189 -1
- package/lib/module/components/SignInStep.js +338 -1
- package/lib/module/components/UniversalOnboarding.js +2770 -1
- package/lib/module/components/VerificationStep.js +168 -1
- package/lib/module/components/WelcomeScreen.js +453 -1
- package/lib/module/components/icons/Basicproficon.js +30 -1
- package/lib/module/components/icons/Basicprofile.js +14 -1
- package/lib/module/components/icons/Checkbox.js +14 -1
- package/lib/module/components/icons/Checkmark.js +20 -1
- package/lib/module/components/icons/Contentanalysis.js +14 -1
- package/lib/module/components/icons/Contenticon.js +32 -1
- package/lib/module/components/icons/EnochE.js +34 -1
- package/lib/module/components/icons/Personalityicon.js +23 -1
- package/lib/module/components/icons/Personalityprofile.js +14 -1
- package/lib/module/components/icons/Personalitytraits.js +14 -1
- package/lib/module/components/icons/Userpreferences.js +14 -1
- package/lib/module/components/icons/index.js +13 -1
- package/lib/module/components/onboarding/OAuthWebView.js +1746 -1
- package/lib/module/components/onboarding/OnboardingHeader.js +66 -1
- package/lib/module/components/onboarding/PinInput.js +274 -1
- package/lib/module/components/onboarding/PlatformConnector.js +240 -1
- package/lib/module/config/PLATFORM_APIS.md +849 -0
- package/lib/module/config/api.js +47 -1
- package/lib/module/constants/index.js +114 -1
- package/lib/module/context/AuthContext.js +335 -1
- package/lib/module/hooks/useConnectedAccounts.js +106 -1
- package/lib/module/hooks/useConnections.js +95 -1
- package/lib/module/hooks/useCredentials.js +171 -6
- package/lib/module/hooks/useUserConnections.js +140 -1
- package/lib/module/index.js +172 -1
- package/lib/module/services/apiClient.js +295 -1
- package/lib/module/services/biometricPinService.js +169 -1
- package/lib/module/services/chatGPTConversationExtractor.js +149 -1
- package/lib/module/services/chatGPTConversationService.js +268 -1
- package/lib/module/services/claudeConversationExtractor.js +97 -1
- package/lib/module/services/claudeConversationService.js +151 -1
- package/lib/module/services/connectedAccountsService.js +293 -1
- package/lib/module/services/googleAuthService.js +241 -1
- package/lib/module/services/hingeDataExtractor.js +99 -1
- package/lib/module/services/hingeDataService.js +143 -1
- package/lib/module/services/imageCompressionService.js +250 -1
- package/lib/module/services/instagramDataExtractor.js +120 -1
- package/lib/module/services/instagramDataService.js +156 -1
- package/lib/module/services/jwtStorageService.js +257 -1
- package/lib/module/services/linkedinDOMExtractor.js +234 -1
- package/lib/module/services/linkedinProfileService.js +210 -1
- package/lib/module/services/linkedinScrapingService.js +219 -1
- package/lib/module/services/llmDataStorage.js +277 -1
- package/lib/module/services/mobileTrainingService.js +173 -1
- package/lib/module/services/netflixDataExtractor.js +114 -1
- package/lib/module/services/netflixDataService.js +191 -1
- package/lib/module/services/pinEncryptionService.js +74 -6
- package/lib/module/services/pinStorageUtils.js +93 -1
- package/lib/module/services/platformAuthService.js +1461 -1
- package/lib/module/services/sephoraDataExtractor.js +134 -1
- package/lib/module/services/sephoraDataService.js +193 -1
- package/lib/module/services/spotifyDataExtractor.js +142 -1
- package/lib/module/services/spotifyDataService.js +234 -1
- package/lib/module/services/storageService.js +383 -1
- package/lib/module/services/telegramDataExtractor.js +109 -1
- package/lib/module/services/telegramDataService.js +493 -1
- package/lib/module/services/trainingApiHelpers.js +67 -1
- package/lib/module/services/userConnectionsService.js +329 -1
- package/lib/module/services/youtubeMigrationService.js +405 -1
- package/lib/module/theme/index.js +245 -1
- package/lib/module/types.js +10 -1
- package/lib/module/utils/Portal.js +90 -1
- package/lib/module/utils/api.js +118 -1
- package/lib/module/utils/assetRegistry.js +200 -34
- package/lib/module/utils/auth.js +100 -1
- package/lib/module/utils/connectorTests.js +600 -27
- package/lib/module/utils/crypto.js +54 -1
- package/lib/module/utils/debugHelper.js +54 -1
- package/lib/module/utils/encryption.js +67 -1
- package/lib/module/utils/eventUtils.js +270 -1
- package/lib/module/utils/haptics.js +59 -8
- package/lib/module/utils/imagePreloader.js +3 -1
- package/lib/module/utils/networkDiagnostics.js +217 -1
- package/lib/module/utils/onairosApi.js +333 -1
- package/lib/module/utils/programmaticFlow.js +111 -1
- package/lib/module/utils/retryHelper.js +211 -1
- package/lib/module/utils/secureStorage.js +330 -6
- package/lib/module/utils/webviewScripts/chatgpt.js +545 -1
- package/lib/module/utils/webviewScripts/claude.js +370 -1
- package/lib/module/utils/webviewScripts/hinge.js +405 -1
- package/lib/module/utils/webviewScripts/index.js +434 -1
- package/lib/module/utils/webviewScripts/instagram.js +448 -1
- package/lib/module/utils/webviewScripts/linkedin.js +874 -1
- package/lib/module/utils/webviewScripts/netflix.js +376 -1
- package/lib/module/utils/webviewScripts/sephora.js +510 -1
- package/lib/module/utils/webviewScripts/spotify.js +413 -1
- package/lib/module/utils/webviewScripts/telegram.js +672 -1
- package/package.json +2 -2
|
@@ -1,8 +1,140 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object['defineProperty'](exports,_0x426a(0x0),{'value':!![]}),exports[_0x426a(0x1)]=void 0x0;function _0x4ade(){const _0x4c57fc=['__esModule','useSephoraDataExtractor','â ī¸\x20[SEPHORA_EXTRACTOR]\x20Invalid\x20loved\x20item:','An\x20unknown\x20error\x20occurred\x20during\x20data\x20storage.','default','â ī¸\x20[SEPHORA_EXTRACTOR]\x20Invalid\x20basket\x20item:','â ī¸\x20[SEPHORA_EXTRACTOR]\x20Invalid\x20order:','xgHOW','number','đ¤\x20[SEPHORA_EXTRACTOR]\x20Username:','AqcFJ','FFJZm','â\x20[SEPHORA_EXTRACTOR]\x20Username\x20is\x20required','Username\x20is\x20required\x20to\x20export\x20Sephora\x20data.','â\x20[SEPHORA_EXTRACTOR]\x20Backend\x20storage\x20failed:','Export\x20Failed','â\x20[SEPHORA_EXTRACTOR]\x20Unexpected\x20error\x20during\x20export:','Failed\x20to\x20connect\x20to\x20the\x20data\x20storage\x20service.\x20Please\x20check\x20your\x20network\x20connection.','lPBlS','TQVJu','idOXr','TQSZw','narhy','vvDBD','QSZkY','PxDvb','â ī¸\x20[SEPHORA_EXTRACTOR]\x20Invalid\x20rating:','log','gNQIn','xLvyV','đ\x20[SEPHORA_EXTRACTOR]\x20Summary:','summary','BLmGA','VoIzr','warn','â ī¸\x20[SEPHORA_EXTRACTOR]\x20Filtered\x20out\x20','lnEtP','\x20invalid\x20items','error','piCqX','Alert','alert','Error','cMLiW','CgNOT','EVtbv','items','length','orders','pEWcO','OAzyt','loves','ratings','HHdwo','basket','name','WEBFj','WkOLU','YNqrD','filter','orderId','JJRwD','woWFi','productId','rating','xczDv','QLVQo','xYrru','jEAmK','YcBmk','RbGcT','pOLJe','TdmGm','HBdcI','Tkmxt','WWKnU','APymu','IdAGR','Vkzcj','Efweb','vINye','iSnYy','eLSXY','storeSephoraData','EJHrC','total','userId','success','đ\x20[SEPHORA_EXTRACTOR]\x20Backend\x20response:','data','EcKKj','viIcO','lRflI','rDUGU'];_0x4ade=function(){return _0x4c57fc;};return _0x4ade();}var _sephoraDataService=__ONAIROS_REQ_FUNC__(0x0),_reactNative=__ONAIROS_REQ_FUNC__(0x1);function _0x426a(_0x4ade3c,_0x426a8e){_0x4ade3c=_0x4ade3c-0x0;const _0x2c0e21=_0x4ade();let _0x4e4f0d=_0x2c0e21[_0x4ade3c];return _0x4e4f0d;}const useSephoraDataExtractor=()=>{const _0xd87212={'lnEtP':function(_0x3c335e,_0x53a4a9){return _0x3c335e-_0x53a4a9;},'PxDvb':_0x426a(0x2),'lPBlS':_0x426a(0x3),'TQVJu':_0x426a(0x4),'idOXr':function(_0x4c4641,_0x49ec3d){return _0x4c4641===_0x49ec3d;},'TQSZw':'HaqKU','narhy':_0x426a(0x5),'vvDBD':_0x426a(0x6),'QSZkY':'âšī¸\x20[SEPHORA_EXTRACTOR]\x20No\x20data\x20to\x20export\x20-\x20treating\x20as\x20success\x20(connected)','Ebhqb':_0x426a(0x7),'dBnrO':_0x426a(0x8),'gNQIn':'đ\x20[SEPHORA_EXTRACTOR]\x20Initiating\x20data\x20export','xLvyV':_0x426a(0x9),'BLmGA':_0x426a(0xa),'VoIzr':_0x426a(0xb),'piCqX':_0x426a(0xc),'cMLiW':_0x426a(0xd),'MZBKr':function(_0x53f9bb,_0x3825df){return _0x53f9bb+_0x3825df;},'CgNOT':function(_0x45fa3e,_0x58ef2d){return _0x45fa3e+_0x58ef2d;},'jEAmK':function(_0xe0a70b,_0x1831ab){return _0xe0a70b===_0x1831ab;},'EVtbv':function(_0x5ddc14,_0x144bae){return _0x5ddc14===_0x144bae;},'pEWcO':function(_0x5519cd,_0x465b6d){return _0x5519cd===_0x465b6d;},'OAzyt':function(_0x121dc5,_0x188976){return _0x121dc5===_0x188976;},'TdmGm':function(_0x1bde10,_0x3d0406){return _0x1bde10===_0x3d0406;},'HHdwo':function(_0x59e2c0,_0x3a4e2d){return _0x59e2c0===_0x3a4e2d;},'MhcDf':function(_0x2756a1,_0x470ff5){return _0x2756a1+_0x470ff5;},'QLVQo':function(_0x2b122b,_0x115be0){return _0x2b122b+_0x115be0;},'xYrru':function(_0x14233e,_0x1de20e){return _0x14233e+_0x1de20e;},'YcBmk':function(_0x531771,_0x5921a8){return _0x531771===_0x5921a8;},'RbGcT':function(_0x245e16,_0x459968){return _0x245e16===_0x459968;},'pOLJe':function(_0x216a07,_0x119bfc){return _0x216a07===_0x119bfc;},'HBdcI':function(_0x23538d,_0x21cd0c){return _0x23538d===_0x21cd0c;},'Tkmxt':function(_0x1c7910,_0x55b45e){return _0x1c7910===_0x55b45e;},'WWKnU':function(_0xc80be7,_0x3e91b2){return _0xc80be7+_0x3e91b2;},'APymu':function(_0x225582,_0x359594){return _0x225582<_0x359594;},'IdAGR':function(_0x22bcea,_0x944bfa){return _0x22bcea===_0x944bfa;},'vINye':function(_0x2da7d5,_0x4e048a){return _0x2da7d5!==_0x4e048a;},'iSnYy':'ErYAp','eLSXY':'GGLqp','EJHrC':function(_0x506b52,_0x81af8a){return _0x506b52===_0x81af8a;},'tgqFA':'â
\x20[SEPHORA_EXTRACTOR]\x20Export\x20completed\x20successfully','EcKKj':_0x426a(0xe),'viIcO':_0x426a(0xf),'lRflI':_0x426a(0x10),'eKxkv':'Export\x20Error','rDUGU':_0x426a(0x11)},_0x33df0a=async(_0x34f503,_0x4ccb62)=>{const _0x9d0ede={'YNqrD':_0xd87212[_0x426a(0x12)],'LTctr':_0xd87212[_0x426a(0x13)],'WgCyK':function(_0x578acb,_0x5bf64b){return _0xd87212[_0x426a(0x14)](_0x578acb,_0x5bf64b);},'WEBFj':_0xd87212[_0x426a(0x15)],'WkOLU':_0xd87212[_0x426a(0x16)],'SEjQR':_0xd87212[_0x426a(0x17)],'zQPCP':_0xd87212[_0x426a(0x18)],'omxBE':function(_0x4dcf25,_0x26edab){return _0x4dcf25!==_0x26edab;},'JJRwD':_0xd87212['Ebhqb'],'woWFi':_0xd87212[_0x426a(0x19)],'xczDv':_0xd87212['dBnrO'],'AhONA':_0x426a(0x1a)};var _0x139247,_0x4e24dd,_0x3d12b6,_0x15c3e8,_0x1b49ff,_0x216b8d,_0x5d4444,_0x5068fb,_0x2428af;console[_0x426a(0x1b)](_0xd87212[_0x426a(0x1c)]),console['log'](_0xd87212[_0x426a(0x1d)],_0x34f503),console[_0x426a(0x1b)](_0x426a(0x1e),_0x4ccb62[_0x426a(0x1f)]);if(!_0x34f503){if(_0xd87212[_0x426a(0x14)](_0xd87212[_0x426a(0x20)],_0xd87212[_0x426a(0x21)]))_0x12de8d[_0x426a(0x22)](_0x426a(0x23)+_0xd87212[_0x426a(0x24)](_0x257b05,_0x1fdb93)+_0x426a(0x25));else return console[_0x426a(0x26)](_0xd87212[_0x426a(0x27)]),_reactNative[_0x426a(0x28)][_0x426a(0x29)](_0x426a(0x2a),_0xd87212[_0x426a(0x2b)],[{'text':'OK','style':_0xd87212[_0x426a(0x13)]}]),![];}const _0x28d0d0=_0xd87212['MZBKr'](_0xd87212[_0x426a(0x2c)]((_0xd87212['jEAmK'](_0x139247=_0x4ccb62['basket'],null)||_0xd87212[_0x426a(0x14)](_0x139247,void 0x0)||_0xd87212[_0x426a(0x2d)](_0x139247=_0x139247[_0x426a(0x2e)],null)||_0xd87212['jEAmK'](_0x139247,void 0x0)?void 0x0:_0x139247[_0x426a(0x2f)])||0x0,(_0xd87212[_0x426a(0x14)](_0x4e24dd=_0x4ccb62[_0x426a(0x30)],null)||_0xd87212[_0x426a(0x31)](_0x4e24dd,void 0x0)?void 0x0:_0x4e24dd[_0x426a(0x2f)])||0x0)+((_0xd87212[_0x426a(0x32)](_0x3d12b6=_0x4ccb62[_0x426a(0x33)],null)||_0x3d12b6===void 0x0?void 0x0:_0x3d12b6[_0x426a(0x2f)])||0x0),((_0x15c3e8=_0x4ccb62[_0x426a(0x34)])===null||_0xd87212['TdmGm'](_0x15c3e8,void 0x0)?void 0x0:_0x15c3e8[_0x426a(0x2f)])||0x0);if(_0xd87212[_0x426a(0x35)](_0x28d0d0,0x0))return console['log']('âšī¸\x20[SEPHORA_EXTRACTOR]\x20No\x20data\x20to\x20export\x20-\x20treating\x20as\x20success\x20(connected)'),!![];const _0x227771=((_0xd87212[_0x426a(0x2d)](_0x1b49ff=_0x4ccb62[_0x426a(0x36)],null)||_0xd87212[_0x426a(0x35)](_0x1b49ff,void 0x0)?void 0x0:_0x1b49ff[_0x426a(0x2e)])||[])['filter'](_0x30888a=>{const _0x26890d=_0x30888a['id']&&_0x30888a[_0x426a(0x37)];if(!_0x26890d){if(_0x9d0ede['WgCyK'](_0x9d0ede[_0x426a(0x38)],'HaqKU'))console[_0x426a(0x22)](_0x9d0ede[_0x426a(0x39)],_0x30888a);else return _0x34b670['error'](_0x426a(0xe),_0x15cc78[_0x426a(0x26)]),_0x1a9969[_0x426a(0x28)][_0x426a(0x29)](_0x426a(0xf),_0x496880[_0x426a(0x26)]||_0x9d0ede[_0x426a(0x3a)],[{'text':'OK','style':_0x9d0ede['LTctr']}]),![];}return _0x26890d;}),_0x1e0cc6=(_0x4ccb62[_0x426a(0x30)]||[])[_0x426a(0x3b)](_0x5bfe47=>{const _0x125e78=_0x5bfe47[_0x426a(0x3c)]&&_0x5bfe47['date'];return!_0x125e78&&console[_0x426a(0x22)](_0x9d0ede['SEjQR'],_0x5bfe47),_0x125e78;}),_0x2ec898=(_0x4ccb62[_0x426a(0x33)]||[])[_0x426a(0x3b)](_0x4e45fd=>{const _0x14c2c3=_0x4e45fd['id']&&_0x4e45fd[_0x426a(0x37)];if(!_0x14c2c3){if(_0x9d0ede['omxBE'](_0x426a(0x7),_0x9d0ede[_0x426a(0x3d)]))return _0x4526aa[_0x426a(0x1b)](_0x9d0ede['zQPCP']),!![];else console[_0x426a(0x22)](_0x9d0ede[_0x426a(0x3e)],_0x4e45fd);}return _0x14c2c3;}),_0x15dbf1=(_0x4ccb62[_0x426a(0x34)]||[])[_0x426a(0x3b)](_0x32763b=>{const _0x173200=_0x32763b[_0x426a(0x3f)]&&typeof _0x32763b[_0x426a(0x40)]===_0x9d0ede[_0x426a(0x41)];return!_0x173200&&console[_0x426a(0x22)](_0x9d0ede['AhONA'],_0x32763b),_0x173200;}),_0x4fd49a=_0xd87212['MhcDf'](_0xd87212[_0x426a(0x42)](_0xd87212[_0x426a(0x43)]((_0xd87212['EVtbv'](_0x216b8d=_0x4ccb62['basket'],null)||_0xd87212[_0x426a(0x35)](_0x216b8d,void 0x0)||_0xd87212[_0x426a(0x44)](_0x216b8d=_0x216b8d['items'],null)||_0xd87212[_0x426a(0x45)](_0x216b8d,void 0x0)?void 0x0:_0x216b8d['length'])||0x0,(_0xd87212[_0x426a(0x46)](_0x5d4444=_0x4ccb62[_0x426a(0x30)],null)||_0xd87212[_0x426a(0x47)](_0x5d4444,void 0x0)?void 0x0:_0x5d4444['length'])||0x0),(_0xd87212[_0x426a(0x48)](_0x5068fb=_0x4ccb62[_0x426a(0x33)],null)||_0xd87212[_0x426a(0x45)](_0x5068fb,void 0x0)?void 0x0:_0x5068fb[_0x426a(0x2f)])||0x0),(_0xd87212[_0x426a(0x49)](_0x2428af=_0x4ccb62[_0x426a(0x34)],null)||_0xd87212[_0x426a(0x4a)](_0x2428af,void 0x0)?void 0x0:_0x2428af[_0x426a(0x2f)])||0x0),_0x28b3e=_0xd87212[_0x426a(0x4b)](_0x227771['length']+_0x1e0cc6[_0x426a(0x2f)],_0x2ec898[_0x426a(0x2f)])+_0x15dbf1[_0x426a(0x2f)];_0xd87212[_0x426a(0x4c)](_0x28b3e,_0x4fd49a)&&(_0xd87212[_0x426a(0x4d)](_0x426a(0x4e),_0x426a(0x4f))?_0xe50688['warn'](_0x9d0ede[_0x426a(0x39)],_0x20b878):console[_0x426a(0x22)](_0x426a(0x23)+_0xd87212[_0x426a(0x24)](_0x4fd49a,_0x28b3e)+_0x426a(0x25)));try{if(_0xd87212[_0x426a(0x50)](_0xd87212[_0x426a(0x51)],_0xd87212[_0x426a(0x52)])){var _0x59f51c;console[_0x426a(0x1b)]('đĄ\x20[SEPHORA_EXTRACTOR]\x20Sending\x20to\x20backend...');const _0x2a60bc=await(0x0,_sephoraDataService[_0x426a(0x53)])(_0x34f503,{'basket':{'items':_0x227771,'total':((_0x59f51c=_0x4ccb62[_0x426a(0x36)])===null||_0xd87212[_0x426a(0x54)](_0x59f51c,void 0x0)?void 0x0:_0x59f51c[_0x426a(0x55)])||0x0,'itemCount':_0x227771[_0x426a(0x2f)]},'orders':_0x1e0cc6,'loves':_0x2ec898,'ratings':_0x15dbf1,'userId':_0x4ccb62[_0x426a(0x56)]});return _0x2a60bc[_0x426a(0x57)]?(console[_0x426a(0x1b)](_0xd87212['tgqFA']),console[_0x426a(0x1b)](_0x426a(0x58),_0x2a60bc[_0x426a(0x59)]),!![]):(console['error'](_0xd87212[_0x426a(0x5a)],_0x2a60bc[_0x426a(0x26)]),_reactNative[_0x426a(0x28)]['alert'](_0xd87212[_0x426a(0x5b)],_0x2a60bc[_0x426a(0x26)]||_0xd87212[_0x426a(0x12)],[{'text':'OK','style':_0xd87212[_0x426a(0x13)]}]),![]);}else _0x2bdf90['warn'](_0xd87212[_0x426a(0x19)],_0x6471b9);}catch(_0x44c6ba){return console[_0x426a(0x26)](_0xd87212[_0x426a(0x5c)],_0x44c6ba),_reactNative[_0x426a(0x28)][_0x426a(0x29)](_0xd87212['eKxkv'],_0xd87212[_0x426a(0x5d)],[{'text':'OK','style':_0x426a(0x4)}]),![];}};return{'initiateDataExport':_0x33df0a};};exports[_0x426a(0x1)]=useSephoraDataExtractor;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSephoraDataExtractor = void 0;
|
|
7
|
+
var _sephoraDataService = require("./sephoraDataService");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
/**
|
|
10
|
+
* Sephora Data Extractor
|
|
11
|
+
*
|
|
12
|
+
* Orchestrates the Sephora data export flow:
|
|
13
|
+
* 1. Receives extracted shopping data from WebView
|
|
14
|
+
* 2. Validates and formats data
|
|
15
|
+
* 3. Sends to backend via sephoraDataService
|
|
16
|
+
*
|
|
17
|
+
* This acts as the bridge between OAuthWebView and the backend API.
|
|
18
|
+
*
|
|
19
|
+
* @reference ChatGPT implementation: src/services/chatGPTConversationExtractor.ts
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Combined Sephora export data from WebView
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Hook for Sephora data extraction operations
|
|
28
|
+
*/
|
|
29
|
+
const useSephoraDataExtractor = () => {
|
|
30
|
+
/**
|
|
31
|
+
* Initiate data export to backend
|
|
32
|
+
*
|
|
33
|
+
* @param username - User identifier
|
|
34
|
+
* @param data - Extracted Sephora data (basket, orders, loves, ratings)
|
|
35
|
+
* @returns true if successful, false otherwise
|
|
36
|
+
*/
|
|
37
|
+
const initiateDataExport = async (username, data) => {
|
|
38
|
+
var _data$basket, _data$orders, _data$loves, _data$ratings, _data$basket2, _data$basket3, _data$orders2, _data$loves2, _data$ratings2;
|
|
39
|
+
console.log('đ [SEPHORA_EXTRACTOR] Initiating data export');
|
|
40
|
+
console.log('đ¤ [SEPHORA_EXTRACTOR] Username:', username);
|
|
41
|
+
console.log('đ [SEPHORA_EXTRACTOR] Summary:', data.summary);
|
|
42
|
+
|
|
43
|
+
// Validation
|
|
44
|
+
if (!username) {
|
|
45
|
+
console.error('â [SEPHORA_EXTRACTOR] Username is required');
|
|
46
|
+
_reactNative.Alert.alert('Error', 'Username is required to export Sephora data.', [{
|
|
47
|
+
text: 'OK',
|
|
48
|
+
style: 'default'
|
|
49
|
+
}]);
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Handle empty data as success - user might be new
|
|
54
|
+
const totalItems = (((_data$basket = data.basket) === null || _data$basket === void 0 || (_data$basket = _data$basket.items) === null || _data$basket === void 0 ? void 0 : _data$basket.length) || 0) + (((_data$orders = data.orders) === null || _data$orders === void 0 ? void 0 : _data$orders.length) || 0) + (((_data$loves = data.loves) === null || _data$loves === void 0 ? void 0 : _data$loves.length) || 0) + (((_data$ratings = data.ratings) === null || _data$ratings === void 0 ? void 0 : _data$ratings.length) || 0);
|
|
55
|
+
if (totalItems === 0) {
|
|
56
|
+
console.log('âšī¸ [SEPHORA_EXTRACTOR] No data to export - treating as success (connected)');
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Validate basket items
|
|
61
|
+
const validBasketItems = (((_data$basket2 = data.basket) === null || _data$basket2 === void 0 ? void 0 : _data$basket2.items) || []).filter(item => {
|
|
62
|
+
const isValid = item.id && item.name;
|
|
63
|
+
if (!isValid) {
|
|
64
|
+
console.warn('â ī¸ [SEPHORA_EXTRACTOR] Invalid basket item:', item);
|
|
65
|
+
}
|
|
66
|
+
return isValid;
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Validate orders
|
|
70
|
+
const validOrders = (data.orders || []).filter(order => {
|
|
71
|
+
const isValid = order.orderId && order.date;
|
|
72
|
+
if (!isValid) {
|
|
73
|
+
console.warn('â ī¸ [SEPHORA_EXTRACTOR] Invalid order:', order);
|
|
74
|
+
}
|
|
75
|
+
return isValid;
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Validate loved products
|
|
79
|
+
const validLoves = (data.loves || []).filter(love => {
|
|
80
|
+
const isValid = love.id && love.name;
|
|
81
|
+
if (!isValid) {
|
|
82
|
+
console.warn('â ī¸ [SEPHORA_EXTRACTOR] Invalid loved item:', love);
|
|
83
|
+
}
|
|
84
|
+
return isValid;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Validate ratings
|
|
88
|
+
const validRatings = (data.ratings || []).filter(rating => {
|
|
89
|
+
const isValid = rating.productId && typeof rating.rating === 'number';
|
|
90
|
+
if (!isValid) {
|
|
91
|
+
console.warn('â ī¸ [SEPHORA_EXTRACTOR] Invalid rating:', rating);
|
|
92
|
+
}
|
|
93
|
+
return isValid;
|
|
94
|
+
});
|
|
95
|
+
const originalCount = (((_data$basket3 = data.basket) === null || _data$basket3 === void 0 || (_data$basket3 = _data$basket3.items) === null || _data$basket3 === void 0 ? void 0 : _data$basket3.length) || 0) + (((_data$orders2 = data.orders) === null || _data$orders2 === void 0 ? void 0 : _data$orders2.length) || 0) + (((_data$loves2 = data.loves) === null || _data$loves2 === void 0 ? void 0 : _data$loves2.length) || 0) + (((_data$ratings2 = data.ratings) === null || _data$ratings2 === void 0 ? void 0 : _data$ratings2.length) || 0);
|
|
96
|
+
const validCount = validBasketItems.length + validOrders.length + validLoves.length + validRatings.length;
|
|
97
|
+
if (validCount < originalCount) {
|
|
98
|
+
console.warn(`â ī¸ [SEPHORA_EXTRACTOR] Filtered out ${originalCount - validCount} invalid items`);
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
var _data$basket4;
|
|
102
|
+
console.log('đĄ [SEPHORA_EXTRACTOR] Sending to backend...');
|
|
103
|
+
const result = await (0, _sephoraDataService.storeSephoraData)(username, {
|
|
104
|
+
basket: {
|
|
105
|
+
items: validBasketItems,
|
|
106
|
+
total: ((_data$basket4 = data.basket) === null || _data$basket4 === void 0 ? void 0 : _data$basket4.total) || 0,
|
|
107
|
+
itemCount: validBasketItems.length
|
|
108
|
+
},
|
|
109
|
+
orders: validOrders,
|
|
110
|
+
loves: validLoves,
|
|
111
|
+
ratings: validRatings,
|
|
112
|
+
userId: data.userId
|
|
113
|
+
});
|
|
114
|
+
if (result.success) {
|
|
115
|
+
console.log('â
[SEPHORA_EXTRACTOR] Export completed successfully');
|
|
116
|
+
console.log('đ [SEPHORA_EXTRACTOR] Backend response:', result.data);
|
|
117
|
+
return true;
|
|
118
|
+
} else {
|
|
119
|
+
console.error('â [SEPHORA_EXTRACTOR] Backend storage failed:', result.error);
|
|
120
|
+
_reactNative.Alert.alert('Export Failed', result.error || 'An unknown error occurred during data storage.', [{
|
|
121
|
+
text: 'OK',
|
|
122
|
+
style: 'default'
|
|
123
|
+
}]);
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.error('â [SEPHORA_EXTRACTOR] Unexpected error during export:', error);
|
|
128
|
+
_reactNative.Alert.alert('Export Error', 'Failed to connect to the data storage service. Please check your network connection.', [{
|
|
129
|
+
text: 'OK',
|
|
130
|
+
style: 'default'
|
|
131
|
+
}]);
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
return {
|
|
136
|
+
initiateDataExport
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
exports.useSephoraDataExtractor = useSephoraDataExtractor;
|
|
140
|
+
//# sourceMappingURL=sephoraDataExtractor.js.map
|
|
@@ -1,9 +1,200 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.storeSephoraData = void 0;
|
|
7
|
+
var _api = require("../config/api");
|
|
8
|
+
var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
|
|
9
|
+
var _reactNative = require("react-native");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
/**
|
|
12
|
+
* Sephora Data Service
|
|
13
|
+
*
|
|
14
|
+
* API layer for storing Sephora shopping data on backend.
|
|
15
|
+
* Sends extracted basket, orders, loves, and ratings to /platform-data/store endpoint.
|
|
16
|
+
*
|
|
17
|
+
* MATCHES ChatGPT implementation pattern
|
|
18
|
+
* - Uses format: { platform, data, metadata }
|
|
19
|
+
* - Platform: "mobile-sephora"
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Structure of a basket item
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Structure of the shopping basket
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Structure of an order item
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Structure of an order
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Structure of a loved/favorited item
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Structure of a product rating
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Combined Sephora data to store
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Response from backend endpoint
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Store Sephora data on backend
|
|
56
|
+
*
|
|
57
|
+
* @param userId - Username or identifier
|
|
58
|
+
* @param data - Sephora shopping data (basket, orders, loves, ratings)
|
|
59
|
+
* @returns Response indicating success/failure with metadata
|
|
60
|
+
*/
|
|
61
|
+
const storeSephoraData = async (userId, data) => {
|
|
62
|
+
console.log('đ [SEPHORA_SERVICE] Storing Sephora data for:', userId);
|
|
63
|
+
console.log('đ [SEPHORA_SERVICE] Basket items:', data.basket.items.length);
|
|
64
|
+
console.log('đ [SEPHORA_SERVICE] Orders:', data.orders.length);
|
|
65
|
+
console.log('đ [SEPHORA_SERVICE] Loved items:', data.loves.length);
|
|
66
|
+
console.log('đ [SEPHORA_SERVICE] Ratings:', data.ratings.length);
|
|
67
|
+
|
|
68
|
+
// Input validation
|
|
69
|
+
if (!userId) {
|
|
70
|
+
console.error('â [SEPHORA_SERVICE] Invalid input: userId missing');
|
|
71
|
+
return {
|
|
72
|
+
success: false,
|
|
73
|
+
error: 'Invalid input: userId missing.'
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
// Get auth token - check all possible storage keys
|
|
78
|
+
const authToken = (await _asyncStorage.default.getItem('onairos_jwt_token')) || (await _asyncStorage.default.getItem('enoch_token')) || (await _asyncStorage.default.getItem('auth_token'));
|
|
79
|
+
if (!authToken) {
|
|
80
|
+
console.error('â [SEPHORA_SERVICE] No auth token found');
|
|
81
|
+
return {
|
|
82
|
+
success: false,
|
|
83
|
+
error: 'Authentication token not found. Please log in again.'
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
console.log('đ [SEPHORA_SERVICE] Auth token found');
|
|
87
|
+
|
|
88
|
+
// Mobile metadata
|
|
89
|
+
const mobileMetadata = {
|
|
90
|
+
platform: _reactNative.Platform.OS,
|
|
91
|
+
appVersion: '1.0.0',
|
|
92
|
+
osVersion: _reactNative.Platform.OS === 'ios' ? '17.0' : _reactNative.Platform.OS,
|
|
93
|
+
deviceModel: _reactNative.Platform.OS === 'ios' ? 'iPhone' : 'Android',
|
|
94
|
+
isOfflineSync: false,
|
|
95
|
+
extractedAt: new Date().toISOString()
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Build request body
|
|
99
|
+
const requestBody = {
|
|
100
|
+
platform: 'mobile-sephora',
|
|
101
|
+
dataType: 'ecommerce',
|
|
102
|
+
data: {
|
|
103
|
+
basket: {
|
|
104
|
+
items: data.basket.items.map(item => ({
|
|
105
|
+
productId: item.id,
|
|
106
|
+
name: item.name,
|
|
107
|
+
brand: item.brand,
|
|
108
|
+
price: item.price,
|
|
109
|
+
quantity: item.quantity,
|
|
110
|
+
category: item.category,
|
|
111
|
+
imageUrl: item.imageUrl
|
|
112
|
+
})),
|
|
113
|
+
total: data.basket.total,
|
|
114
|
+
itemCount: data.basket.itemCount
|
|
115
|
+
},
|
|
116
|
+
orders: data.orders.map(order => ({
|
|
117
|
+
orderId: order.orderId,
|
|
118
|
+
date: order.date,
|
|
119
|
+
total: order.total,
|
|
120
|
+
status: order.status,
|
|
121
|
+
items: order.items.map(item => ({
|
|
122
|
+
productId: item.id,
|
|
123
|
+
name: item.name,
|
|
124
|
+
brand: item.brand,
|
|
125
|
+
price: item.price,
|
|
126
|
+
quantity: item.quantity
|
|
127
|
+
}))
|
|
128
|
+
})),
|
|
129
|
+
loves: data.loves.map(love => ({
|
|
130
|
+
productId: love.id,
|
|
131
|
+
name: love.name,
|
|
132
|
+
brand: love.brand,
|
|
133
|
+
category: love.category,
|
|
134
|
+
price: love.price,
|
|
135
|
+
rating: love.rating,
|
|
136
|
+
addedAt: love.addedAt,
|
|
137
|
+
type: 'love'
|
|
138
|
+
})),
|
|
139
|
+
ratings: data.ratings.map(rating => ({
|
|
140
|
+
productId: rating.productId,
|
|
141
|
+
productName: rating.productName,
|
|
142
|
+
score: rating.rating,
|
|
143
|
+
review: rating.review,
|
|
144
|
+
date: rating.date,
|
|
145
|
+
isRecommended: rating.isRecommended,
|
|
146
|
+
sentiment: rating.type
|
|
147
|
+
})),
|
|
148
|
+
sephoraUserId: data.userId
|
|
149
|
+
},
|
|
150
|
+
summary: {
|
|
151
|
+
basketItemCount: data.basket.items.length,
|
|
152
|
+
basketTotal: data.basket.total,
|
|
153
|
+
orderCount: data.orders.length,
|
|
154
|
+
lovedProductCount: data.loves.length,
|
|
155
|
+
ratingCount: data.ratings.length,
|
|
156
|
+
positiveRatings: data.ratings.filter(r => r.type === 'positive').length,
|
|
157
|
+
negativeRatings: data.ratings.filter(r => r.type === 'negative').length
|
|
158
|
+
},
|
|
159
|
+
mobileMetadata: mobileMetadata
|
|
160
|
+
};
|
|
161
|
+
console.log('đĄ [SEPHORA_SERVICE] Sending to backend...');
|
|
162
|
+
console.log('đ [SEPHORA_SERVICE] URL:', `${_api.API_CONFIG.BASE_URL}/platform-data/store`);
|
|
163
|
+
const response = await fetch(`${_api.API_CONFIG.BASE_URL}/platform-data/store`, {
|
|
164
|
+
method: 'POST',
|
|
165
|
+
headers: {
|
|
166
|
+
'Content-Type': 'application/json',
|
|
167
|
+
'Authorization': `Bearer ${authToken}`,
|
|
168
|
+
'User-Agent': `OnairosSDK/1.0.0 (${_reactNative.Platform.OS})`
|
|
169
|
+
},
|
|
170
|
+
body: JSON.stringify(requestBody)
|
|
171
|
+
});
|
|
172
|
+
const responseData = await response.json();
|
|
173
|
+
if (response.ok) {
|
|
174
|
+
console.log('â
[SEPHORA_SERVICE] Successfully stored Sephora data');
|
|
175
|
+
if (responseData.message) {
|
|
176
|
+
console.log(`đ [SEPHORA_SERVICE] Backend response: ${responseData.message}`);
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
success: true,
|
|
180
|
+
message: responseData.message || 'Sephora data stored successfully',
|
|
181
|
+
data: responseData.data
|
|
182
|
+
};
|
|
183
|
+
} else {
|
|
184
|
+
console.warn(`â ī¸ [SEPHORA_SERVICE] Backend returned status: ${response.status}`);
|
|
185
|
+
console.warn(`â ī¸ [SEPHORA_SERVICE] Error: ${responseData.error || 'Unknown error'}`);
|
|
186
|
+
return {
|
|
187
|
+
success: false,
|
|
188
|
+
error: responseData.error || `HTTP ${response.status}`
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
} catch (error) {
|
|
192
|
+
console.error('â [SEPHORA_SERVICE] Network error:', error);
|
|
193
|
+
return {
|
|
194
|
+
success: false,
|
|
195
|
+
error: error.message || 'Network error. Please check your connection.'
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
exports.storeSephoraData = storeSephoraData;
|
|
200
|
+
//# sourceMappingURL=sephoraDataService.js.map
|
|
@@ -1,8 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object[_0x6cce(0x0)](exports,_0x6cce(0x1),{'value':!![]}),exports['useSpotifyDataExtractor']=void 0x0;var _spotifyDataService=__ONAIROS_REQ_FUNC__(0x0),_reactNative=__ONAIROS_REQ_FUNC__(0x1);function _0x6cce(_0x25f55c,_0x6cce46){_0x25f55c=_0x25f55c-0x0;const _0x3a3f20=_0x25f5();let _0x58a8c8=_0x3a3f20[_0x25f55c];return _0x58a8c8;}function _0x25f5(){const _0x25a8eb=['defineProperty','__esModule','LcIBa','TiHRR','â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20saved\x20track:','â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20saved\x20album:','ggzye','Export\x20Error','default','Export\x20Failed','đ\x20[SPOTIFY_EXTRACTOR]\x20Summary:','â\x20[SPOTIFY_EXTRACTOR]\x20Username\x20is\x20required','xpDmM','medium_term','â
\x20[SPOTIFY_EXTRACTOR]\x20Export\x20completed\x20successfully','đ\x20[SPOTIFY_EXTRACTOR]\x20Backend\x20response:','â\x20[SPOTIFY_EXTRACTOR]\x20Backend\x20storage\x20failed:','An\x20unknown\x20error\x20occurred\x20during\x20data\x20storage.','â\x20[SPOTIFY_EXTRACTOR]\x20Unexpected\x20error\x20during\x20export:','Failed\x20to\x20connect\x20to\x20the\x20data\x20storage\x20service.\x20Please\x20check\x20your\x20network\x20connection.','â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20top\x20artist:','tKBiZ','VmgTC','â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20top\x20track:','mVpbY','RxgjY','aezdT','log','qtBLd','summary','error','rTZqt','Alert','alert','Error','Username\x20is\x20required\x20to\x20export\x20Spotify\x20data.','OxPAT','LvwWV','recentlyPlayed','LOUkA','items','lrngH','length','MDpZD','topItems','JlbTL','artists','playlists','savedTracks','crJaP','savedAlbums','âšī¸\x20[SPOTIFY_EXTRACTOR]\x20No\x20data\x20to\x20export\x20-\x20treating\x20as\x20success\x20(connected)','NpGRy','trackId','name','XYrhF','eIVOz','warn','oJtQl','kgLqI','asuFg','tracks','filter','VWEYJ','Vpcbi','â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Filtered\x20out\x20','\x20invalid\x20items','nIggW','XgLzC','Dvkqv','MKREs','hHQMv','OZgeX','YYpyR','MIsPN','nLHNw','albumId','BTOqn','KOTpn','ZiLxB','ccdjB','đĄ\x20[SPOTIFY_EXTRACTOR]\x20Sending\x20to\x20backend...','storeSpotifyData','timeRange','HMwxs','profile','tokenExpiry','userId','success','TcoVO','KjsiY','data','ByqpL','mQchR','THkYV','lCWSD','useSpotifyDataExtractor'];_0x25f5=function(){return _0x25a8eb;};return _0x25f5();}const useSpotifyDataExtractor=()=>{const _0x161cbc={'tKBiZ':function(_0x1ba5d4,_0x4cd22e){return _0x1ba5d4!==_0x4cd22e;},'nIggW':_0x6cce(0x2),'XgLzC':'FYbYV','Dvkqv':_0x6cce(0x3),'YYpyR':_0x6cce(0x4),'BTOqn':_0x6cce(0x5),'VmgTC':'hjmKq','mVpbY':_0x6cce(0x6),'THkYV':_0x6cce(0x7),'RxgjY':_0x6cce(0x8),'aezdT':_0x6cce(0x9),'qtBLd':_0x6cce(0xa),'rTZqt':_0x6cce(0xb),'OxPAT':function(_0x42515d,_0x26aab5){return _0x42515d+_0x26aab5;},'LvwWV':function(_0x1792e0,_0x54aa7c){return _0x1792e0+_0x54aa7c;},'lrngH':function(_0x3c892b,_0x1992ce){return _0x3c892b===_0x1992ce;},'LOUkA':function(_0x334254,_0x3f86b8){return _0x334254===_0x3f86b8;},'MDpZD':function(_0x1facac,_0x32c9d0){return _0x1facac===_0x32c9d0;},'JlbTL':function(_0x1d06f6,_0x299571){return _0x1d06f6===_0x299571;},'crJaP':function(_0x2039b8,_0x33c97b){return _0x2039b8===_0x33c97b;},'asuFg':function(_0x4ed6f7,_0x35c13b){return _0x4ed6f7===_0x35c13b;},'NpGRy':function(_0x27f83a,_0x5551d9){return _0x27f83a===_0x5551d9;},'kgLqI':function(_0x58af93,_0x10b2e5){return _0x58af93===_0x10b2e5;},'KOTpn':function(_0x5651c5,_0x2ead4d){return _0x5651c5+_0x2ead4d;},'xuoJP':function(_0x2f5275,_0xabfa0d){return _0x2f5275<_0xabfa0d;},'ZiLxB':function(_0x164f02,_0x5b9f57){return _0x164f02!==_0x5b9f57;},'ccdjB':_0x6cce(0xc),'jvWRe':function(_0x1a9a1e,_0x174898){return _0x1a9a1e===_0x174898;},'HMwxs':_0x6cce(0xd),'TcoVO':_0x6cce(0xe),'KjsiY':_0x6cce(0xf),'OvNyX':_0x6cce(0x10),'ByqpL':_0x6cce(0x11),'mQchR':_0x6cce(0x12),'lCWSD':_0x6cce(0x13)},_0x92bada=async(_0xa4ae7c,_0x50bbc0)=>{const _0x153e64={'Vpcbi':_0x6cce(0x14),'XYrhF':function(_0x2a60a4,_0x297042){return _0x161cbc[_0x6cce(0x15)](_0x2a60a4,_0x297042);},'DhLvZ':_0x161cbc[_0x6cce(0x16)],'oJtQl':'â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20recently\x20played\x20track:','VWEYJ':_0x6cce(0x17),'sfVWb':_0x161cbc[_0x6cce(0x18)],'VsLuL':'â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20playlist:','MKREs':'â\x20[SPOTIFY_EXTRACTOR]\x20Unexpected\x20error\x20during\x20export:','hHQMv':_0x161cbc['THkYV'],'OZgeX':'Failed\x20to\x20connect\x20to\x20the\x20data\x20storage\x20service.\x20Please\x20check\x20your\x20network\x20connection.','nLHNw':_0x161cbc[_0x6cce(0x19)],'MIsPN':_0x161cbc[_0x6cce(0x1a)]};var _0xa953a3,_0x3731b8,_0x11ecfd,_0x57866e,_0x8e5f27,_0x5df3d1,_0x197be5,_0x531005,_0x31d4ea;console['log']('đ\x20[SPOTIFY_EXTRACTOR]\x20Initiating\x20data\x20export'),console[_0x6cce(0x1b)]('đ¤\x20[SPOTIFY_EXTRACTOR]\x20Username:',_0xa4ae7c),console[_0x6cce(0x1b)](_0x161cbc[_0x6cce(0x1c)],_0x50bbc0[_0x6cce(0x1d)]);if(!_0xa4ae7c)return console[_0x6cce(0x1e)](_0x161cbc[_0x6cce(0x1f)]),_reactNative[_0x6cce(0x20)][_0x6cce(0x21)](_0x6cce(0x22),_0x6cce(0x23),[{'text':'OK','style':_0x161cbc[_0x6cce(0x19)]}]),![];const _0x506268=_0x161cbc[_0x6cce(0x24)](_0x161cbc[_0x6cce(0x25)](_0x161cbc['OxPAT'](((_0xa953a3=_0x50bbc0[_0x6cce(0x26)])===null||_0x161cbc['lrngH'](_0xa953a3,void 0x0)||_0x161cbc[_0x6cce(0x27)](_0xa953a3=_0xa953a3[_0x6cce(0x28)],null)||_0x161cbc[_0x6cce(0x29)](_0xa953a3,void 0x0)?void 0x0:_0xa953a3[_0x6cce(0x2a)])||0x0,((_0x3731b8=_0x50bbc0['topItems'])===null||_0x161cbc[_0x6cce(0x27)](_0x3731b8,void 0x0)||(_0x3731b8=_0x3731b8['tracks'])===null||_0x161cbc[_0x6cce(0x2b)](_0x3731b8,void 0x0)?void 0x0:_0x3731b8['length'])||0x0)+(((_0x11ecfd=_0x50bbc0[_0x6cce(0x2c)])===null||_0x161cbc[_0x6cce(0x2d)](_0x11ecfd,void 0x0)||_0x161cbc[_0x6cce(0x2d)](_0x11ecfd=_0x11ecfd[_0x6cce(0x2e)],null)||_0x161cbc['MDpZD'](_0x11ecfd,void 0x0)?void 0x0:_0x11ecfd[_0x6cce(0x2a)])||0x0)+((_0x161cbc[_0x6cce(0x29)](_0x57866e=_0x50bbc0[_0x6cce(0x2f)],null)||_0x161cbc[_0x6cce(0x2b)](_0x57866e,void 0x0)?void 0x0:_0x57866e[_0x6cce(0x2a)])||0x0),(_0x161cbc['crJaP'](_0x8e5f27=_0x50bbc0[_0x6cce(0x30)],null)||_0x161cbc['asuFg'](_0x8e5f27,void 0x0)?void 0x0:_0x8e5f27[_0x6cce(0x2a)])||0x0),(_0x161cbc[_0x6cce(0x31)](_0x5df3d1=_0x50bbc0[_0x6cce(0x32)],null)||_0x161cbc[_0x6cce(0x2b)](_0x5df3d1,void 0x0)?void 0x0:_0x5df3d1[_0x6cce(0x2a)])||0x0);if(_0x161cbc[_0x6cce(0x2d)](_0x506268,0x0))return console[_0x6cce(0x1b)](_0x6cce(0x33)),!![];const _0x4b8b44=((_0x161cbc[_0x6cce(0x34)](_0x197be5=_0x50bbc0['recentlyPlayed'],null)||_0x197be5===void 0x0?void 0x0:_0x197be5[_0x6cce(0x28)])||[])['filter'](_0x4d5dee=>{const _0x3e3a84=_0x4d5dee[_0x6cce(0x35)]&&_0x4d5dee[_0x6cce(0x36)];return!_0x3e3a84&&(_0x153e64[_0x6cce(0x37)](_0x6cce(0x38),_0x153e64['DhLvZ'])?console[_0x6cce(0x39)](_0x153e64[_0x6cce(0x3a)],_0x4d5dee):_0x30a0b7[_0x6cce(0x39)](_0x153e64['Vpcbi'],_0x3d7f07)),_0x3e3a84;}),_0x5aac21=((_0x161cbc[_0x6cce(0x3b)](_0x531005=_0x50bbc0['topItems'],null)||_0x161cbc[_0x6cce(0x3c)](_0x531005,void 0x0)?void 0x0:_0x531005[_0x6cce(0x3d)])||[])[_0x6cce(0x3e)](_0x47e82d=>{const _0x54eb68=_0x47e82d[_0x6cce(0x35)]&&_0x47e82d[_0x6cce(0x36)];return!_0x54eb68&&console[_0x6cce(0x39)](_0x153e64[_0x6cce(0x3f)],_0x47e82d),_0x54eb68;}),_0x375cad=(((_0x31d4ea=_0x50bbc0[_0x6cce(0x2c)])===null||_0x161cbc[_0x6cce(0x31)](_0x31d4ea,void 0x0)?void 0x0:_0x31d4ea[_0x6cce(0x2e)])||[])[_0x6cce(0x3e)](_0xeb7652=>{const _0x6b7772=_0xeb7652['artistId']&&_0xeb7652['name'];return!_0x6b7772&&console['warn'](_0x153e64[_0x6cce(0x40)],_0xeb7652),_0x6b7772;}),_0x3c5424=(_0x50bbc0[_0x6cce(0x2f)]||[])[_0x6cce(0x3e)](_0x3a20cb=>{const _0x15c418=_0x3a20cb['playlistId']&&_0x3a20cb[_0x6cce(0x36)];return!_0x15c418&&(_0x153e64[_0x6cce(0x37)](_0x6cce(0x6),_0x153e64['sfVWb'])?_0x46d70a['warn'](_0x6cce(0x41)+(_0x37b983-_0x287f3e)+_0x6cce(0x42)):console[_0x6cce(0x39)](_0x153e64['VsLuL'],_0x3a20cb)),_0x15c418;}),_0x448c55=(_0x50bbc0[_0x6cce(0x30)]||[])[_0x6cce(0x3e)](_0x47e82e=>{if(_0x161cbc['tKBiZ'](_0x161cbc[_0x6cce(0x43)],_0x161cbc[_0x6cce(0x44)])){const _0x528e0b=_0x47e82e[_0x6cce(0x35)]&&_0x47e82e[_0x6cce(0x36)];if(!_0x528e0b){if(_0x161cbc[_0x6cce(0x45)]!==_0x6cce(0x3))return _0xe4b37a[_0x6cce(0x1e)](_0x153e64[_0x6cce(0x46)],_0x24a47e),_0xf91d71[_0x6cce(0x20)][_0x6cce(0x21)](_0x153e64[_0x6cce(0x47)],_0x153e64[_0x6cce(0x48)],[{'text':'OK','style':_0x153e64['nLHNw']}]),![];else console[_0x6cce(0x39)](_0x161cbc[_0x6cce(0x49)],_0x47e82e);}return _0x528e0b;}else return _0x57abaa[_0x6cce(0x1e)](_0x6cce(0x10),_0x50d7b3['error']),_0x11d841[_0x6cce(0x20)][_0x6cce(0x21)](_0x153e64[_0x6cce(0x4a)],_0x2aac08[_0x6cce(0x1e)]||_0x6cce(0x11),[{'text':'OK','style':_0x153e64[_0x6cce(0x4b)]}]),![];}),_0x36b48c=(_0x50bbc0[_0x6cce(0x32)]||[])[_0x6cce(0x3e)](_0x7cc00c=>{const _0x3433bc=_0x7cc00c[_0x6cce(0x4c)]&&_0x7cc00c[_0x6cce(0x36)];return!_0x3433bc&&console['warn'](_0x161cbc[_0x6cce(0x4d)],_0x7cc00c),_0x3433bc;}),_0x13d7d4=_0x506268,_0x3fa18e=_0x161cbc[_0x6cce(0x25)](_0x161cbc[_0x6cce(0x4e)](_0x161cbc[_0x6cce(0x24)](_0x161cbc['OxPAT'](_0x4b8b44[_0x6cce(0x2a)],_0x5aac21[_0x6cce(0x2a)]),_0x375cad['length']),_0x3c5424[_0x6cce(0x2a)]),_0x448c55[_0x6cce(0x2a)])+_0x36b48c[_0x6cce(0x2a)];_0x161cbc['xuoJP'](_0x3fa18e,_0x13d7d4)&&console['warn'](_0x6cce(0x41)+(_0x13d7d4-_0x3fa18e)+'\x20invalid\x20items');try{if(_0x161cbc[_0x6cce(0x4f)](_0x161cbc[_0x6cce(0x50)],_0x161cbc[_0x6cce(0x50)]))_0x436a86['warn'](_0x153e64[_0x6cce(0x3a)],_0x41bcb9);else{var _0xb15414;console[_0x6cce(0x1b)](_0x6cce(0x51));const _0xcbacb1=await(0x0,_spotifyDataService[_0x6cce(0x52)])(_0xa4ae7c,{'recentlyPlayed':{'items':_0x4b8b44,'totalCount':_0x4b8b44['length']},'topItems':{'tracks':_0x5aac21,'artists':_0x375cad,'timeRange':(_0x161cbc['jvWRe'](_0xb15414=_0x50bbc0[_0x6cce(0x2c)],null)||_0xb15414===void 0x0?void 0x0:_0xb15414[_0x6cce(0x53)])||_0x161cbc[_0x6cce(0x54)]},'playlists':_0x3c5424,'savedTracks':_0x448c55,'savedAlbums':_0x36b48c,'profile':_0x50bbc0[_0x6cce(0x55)],'tokenExpiry':_0x50bbc0[_0x6cce(0x56)],'userId':_0x50bbc0[_0x6cce(0x57)]});return _0xcbacb1[_0x6cce(0x58)]?(console['log'](_0x161cbc[_0x6cce(0x59)]),console['log'](_0x161cbc[_0x6cce(0x5a)],_0xcbacb1[_0x6cce(0x5b)]),!![]):(console['error'](_0x161cbc['OvNyX'],_0xcbacb1[_0x6cce(0x1e)]),_reactNative[_0x6cce(0x20)][_0x6cce(0x21)](_0x161cbc[_0x6cce(0x1a)],_0xcbacb1[_0x6cce(0x1e)]||_0x161cbc[_0x6cce(0x5c)],[{'text':'OK','style':_0x161cbc[_0x6cce(0x19)]}]),![]);}}catch(_0x4055d2){return console[_0x6cce(0x1e)](_0x161cbc[_0x6cce(0x5d)],_0x4055d2),_reactNative[_0x6cce(0x20)][_0x6cce(0x21)](_0x161cbc[_0x6cce(0x5e)],_0x161cbc[_0x6cce(0x5f)],[{'text':'OK','style':_0x161cbc['RxgjY']}]),![];}};return{'initiateDataExport':_0x92bada};};exports[_0x6cce(0x60)]=useSpotifyDataExtractor;
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSpotifyDataExtractor = void 0;
|
|
7
|
+
var _spotifyDataService = require("./spotifyDataService");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
/**
|
|
10
|
+
* Spotify Data Extractor
|
|
11
|
+
*
|
|
12
|
+
* Orchestrates the Spotify data export flow:
|
|
13
|
+
* 1. Receives extracted listening data from WebView
|
|
14
|
+
* 2. Validates and formats data
|
|
15
|
+
* 3. Sends to backend via spotifyDataService
|
|
16
|
+
*
|
|
17
|
+
* This acts as the bridge between OAuthWebView and the backend API.
|
|
18
|
+
*
|
|
19
|
+
* @reference Sephora implementation: src/services/sephoraDataExtractor.ts
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Combined Spotify export data from WebView - matches spotify.ts script output
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Hook for Spotify data extraction operations
|
|
28
|
+
*/
|
|
29
|
+
const useSpotifyDataExtractor = () => {
|
|
30
|
+
/**
|
|
31
|
+
* Initiate data export to backend
|
|
32
|
+
*
|
|
33
|
+
* @param username - User identifier
|
|
34
|
+
* @param data - Extracted Spotify data (recentlyPlayed, topItems, playlists, etc.)
|
|
35
|
+
* @returns true if successful, false otherwise
|
|
36
|
+
*/
|
|
37
|
+
const initiateDataExport = async (username, data) => {
|
|
38
|
+
var _data$recentlyPlayed, _data$topItems, _data$topItems2, _data$playlists, _data$savedTracks, _data$savedAlbums, _data$recentlyPlayed2, _data$topItems3, _data$topItems4;
|
|
39
|
+
console.log('đ [SPOTIFY_EXTRACTOR] Initiating data export');
|
|
40
|
+
console.log('đ¤ [SPOTIFY_EXTRACTOR] Username:', username);
|
|
41
|
+
console.log('đ [SPOTIFY_EXTRACTOR] Summary:', data.summary);
|
|
42
|
+
if (!username) {
|
|
43
|
+
console.error('â [SPOTIFY_EXTRACTOR] Username is required');
|
|
44
|
+
_reactNative.Alert.alert('Error', 'Username is required to export Spotify data.', [{
|
|
45
|
+
text: 'OK',
|
|
46
|
+
style: 'default'
|
|
47
|
+
}]);
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const totalItems = (((_data$recentlyPlayed = data.recentlyPlayed) === null || _data$recentlyPlayed === void 0 || (_data$recentlyPlayed = _data$recentlyPlayed.items) === null || _data$recentlyPlayed === void 0 ? void 0 : _data$recentlyPlayed.length) || 0) + (((_data$topItems = data.topItems) === null || _data$topItems === void 0 || (_data$topItems = _data$topItems.tracks) === null || _data$topItems === void 0 ? void 0 : _data$topItems.length) || 0) + (((_data$topItems2 = data.topItems) === null || _data$topItems2 === void 0 || (_data$topItems2 = _data$topItems2.artists) === null || _data$topItems2 === void 0 ? void 0 : _data$topItems2.length) || 0) + (((_data$playlists = data.playlists) === null || _data$playlists === void 0 ? void 0 : _data$playlists.length) || 0) + (((_data$savedTracks = data.savedTracks) === null || _data$savedTracks === void 0 ? void 0 : _data$savedTracks.length) || 0) + (((_data$savedAlbums = data.savedAlbums) === null || _data$savedAlbums === void 0 ? void 0 : _data$savedAlbums.length) || 0);
|
|
51
|
+
if (totalItems === 0) {
|
|
52
|
+
console.log('âšī¸ [SPOTIFY_EXTRACTOR] No data to export - treating as success (connected)');
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
const validRecentlyPlayed = (((_data$recentlyPlayed2 = data.recentlyPlayed) === null || _data$recentlyPlayed2 === void 0 ? void 0 : _data$recentlyPlayed2.items) || []).filter(track => {
|
|
56
|
+
const isValid = track.trackId && track.name;
|
|
57
|
+
if (!isValid) {
|
|
58
|
+
console.warn('â ī¸ [SPOTIFY_EXTRACTOR] Invalid recently played track:', track);
|
|
59
|
+
}
|
|
60
|
+
return isValid;
|
|
61
|
+
});
|
|
62
|
+
const validTopTracks = (((_data$topItems3 = data.topItems) === null || _data$topItems3 === void 0 ? void 0 : _data$topItems3.tracks) || []).filter(track => {
|
|
63
|
+
const isValid = track.trackId && track.name;
|
|
64
|
+
if (!isValid) {
|
|
65
|
+
console.warn('â ī¸ [SPOTIFY_EXTRACTOR] Invalid top track:', track);
|
|
66
|
+
}
|
|
67
|
+
return isValid;
|
|
68
|
+
});
|
|
69
|
+
const validTopArtists = (((_data$topItems4 = data.topItems) === null || _data$topItems4 === void 0 ? void 0 : _data$topItems4.artists) || []).filter(artist => {
|
|
70
|
+
const isValid = artist.artistId && artist.name;
|
|
71
|
+
if (!isValid) {
|
|
72
|
+
console.warn('â ī¸ [SPOTIFY_EXTRACTOR] Invalid top artist:', artist);
|
|
73
|
+
}
|
|
74
|
+
return isValid;
|
|
75
|
+
});
|
|
76
|
+
const validPlaylists = (data.playlists || []).filter(playlist => {
|
|
77
|
+
const isValid = playlist.playlistId && playlist.name;
|
|
78
|
+
if (!isValid) {
|
|
79
|
+
console.warn('â ī¸ [SPOTIFY_EXTRACTOR] Invalid playlist:', playlist);
|
|
80
|
+
}
|
|
81
|
+
return isValid;
|
|
82
|
+
});
|
|
83
|
+
const validSavedTracks = (data.savedTracks || []).filter(track => {
|
|
84
|
+
const isValid = track.trackId && track.name;
|
|
85
|
+
if (!isValid) {
|
|
86
|
+
console.warn('â ī¸ [SPOTIFY_EXTRACTOR] Invalid saved track:', track);
|
|
87
|
+
}
|
|
88
|
+
return isValid;
|
|
89
|
+
});
|
|
90
|
+
const validSavedAlbums = (data.savedAlbums || []).filter(album => {
|
|
91
|
+
const isValid = album.albumId && album.name;
|
|
92
|
+
if (!isValid) {
|
|
93
|
+
console.warn('â ī¸ [SPOTIFY_EXTRACTOR] Invalid saved album:', album);
|
|
94
|
+
}
|
|
95
|
+
return isValid;
|
|
96
|
+
});
|
|
97
|
+
const originalCount = totalItems;
|
|
98
|
+
const validCount = validRecentlyPlayed.length + validTopTracks.length + validTopArtists.length + validPlaylists.length + validSavedTracks.length + validSavedAlbums.length;
|
|
99
|
+
if (validCount < originalCount) {
|
|
100
|
+
console.warn(`â ī¸ [SPOTIFY_EXTRACTOR] Filtered out ${originalCount - validCount} invalid items`);
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
var _data$topItems5;
|
|
104
|
+
console.log('đĄ [SPOTIFY_EXTRACTOR] Sending to backend...');
|
|
105
|
+
const result = await (0, _spotifyDataService.storeSpotifyData)(username, {
|
|
106
|
+
recentlyPlayed: {
|
|
107
|
+
items: validRecentlyPlayed,
|
|
108
|
+
totalCount: validRecentlyPlayed.length
|
|
109
|
+
},
|
|
110
|
+
topItems: {
|
|
111
|
+
tracks: validTopTracks,
|
|
112
|
+
artists: validTopArtists,
|
|
113
|
+
timeRange: ((_data$topItems5 = data.topItems) === null || _data$topItems5 === void 0 ? void 0 : _data$topItems5.timeRange) || 'medium_term'
|
|
114
|
+
},
|
|
115
|
+
playlists: validPlaylists,
|
|
116
|
+
savedTracks: validSavedTracks,
|
|
117
|
+
savedAlbums: validSavedAlbums,
|
|
118
|
+
profile: data.profile,
|
|
119
|
+
tokenExpiry: data.tokenExpiry,
|
|
120
|
+
userId: data.userId
|
|
121
|
+
});
|
|
122
|
+
if (result.success) {
|
|
123
|
+
console.log('â
[SPOTIFY_EXTRACTOR] Export completed successfully');
|
|
124
|
+
console.log('đ [SPOTIFY_EXTRACTOR] Backend response:', result.data);
|
|
125
|
+
return true;
|
|
126
|
+
} else {
|
|
127
|
+
console.error('â [SPOTIFY_EXTRACTOR] Backend storage failed:', result.error);
|
|
128
|
+
_reactNative.Alert.alert('Export Failed', result.error || 'An unknown error occurred during data storage.', [{
|
|
129
|
+
text: 'OK',
|
|
130
|
+
style: 'default'
|
|
131
|
+
}]);
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
} catch (error) {
|
|
135
|
+
console.error('â [SPOTIFY_EXTRACTOR] Unexpected error during export:', error);
|
|
136
|
+
_reactNative.Alert.alert('Export Error', 'Failed to connect to the data storage service. Please check your network connection.', [{
|
|
137
|
+
text: 'OK',
|
|
138
|
+
style: 'default'
|
|
139
|
+
}]);
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
return {
|
|
144
|
+
initiateDataExport
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
exports.useSpotifyDataExtractor = useSpotifyDataExtractor;
|
|
148
|
+
//# sourceMappingURL=spotifyDataExtractor.js.map
|