@onairos/react-native 3.7.1 â 3.7.3
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/assets/icons/spotify.png +0 -0
- package/lib/commonjs/assets/images/spotify.png +0 -0
- package/lib/commonjs/components/BodyText.js +27 -9
- package/lib/commonjs/components/BrandMark.js +111 -10
- package/lib/commonjs/components/CodeInput.js +116 -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/assets/icons/spotify.png +0 -0
- package/lib/module/assets/images/spotify.png +0 -0
- package/lib/module/components/BodyText.js +20 -1
- package/lib/module/components/BrandMark.js +104 -1
- package/lib/module/components/CodeInput.js +109 -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
|
-
|
|
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[_0xb10e(0x0)](exports,_0xb10e(0x1),{'value':!![]}),exports['useSpotifyDataExtractor']=void 0x0;var _spotifyDataService=__ONAIROS_REQ_FUNC__(0x0),_reactNative=__ONAIROS_REQ_FUNC__(0x1);function _0xb10e(_0x16f9a3,_0xb10e33){_0x16f9a3=_0x16f9a3-0x0;const _0x1f784a=_0x16f9();let _0x279165=_0x1f784a[_0x16f9a3];return _0x279165;}const useSpotifyDataExtractor=()=>{const _0xf204b={'lZMxH':_0xb10e(0x2),'NyUgM':_0xb10e(0x3),'VQnwW':'â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20recently\x20played\x20track:','xFxMd':function(_0x3ac874,_0x121b56){return _0x3ac874===_0x121b56;},'Mcgna':'Qyezf','GKsoV':_0xb10e(0x4),'bKxHB':function(_0x5272f8,_0x124c62){return _0x5272f8!==_0x124c62;},'oxUre':_0xb10e(0x5),'yeHTU':_0xb10e(0x6),'XhkLn':_0xb10e(0x7),'gVObB':_0xb10e(0x8),'dURFj':_0xb10e(0x9),'kAuDS':_0xb10e(0xa),'URsBm':_0xb10e(0xb),'GLtIZ':_0xb10e(0xc),'jjNso':_0xb10e(0xd),'VVXyK':function(_0x5c5310,_0x3a6c30){return _0x5c5310===_0x3a6c30;},'aZTuJ':_0xb10e(0xe),'viHFb':_0xb10e(0xf),'tMoUe':_0xb10e(0x10),'vnusH':'Error','OvMJC':_0xb10e(0x11),'jlCCw':_0xb10e(0x12),'RJsOQ':function(_0x5ee0d9,_0x261d81){return _0x5ee0d9+_0x261d81;},'qplLM':function(_0x2418dc,_0x2cb906){return _0x2418dc+_0x2cb906;},'WvcjD':function(_0x8c3781,_0x593000){return _0x8c3781+_0x593000;},'EBdSr':function(_0x2834e1,_0x28ec50){return _0x2834e1===_0x28ec50;},'OjTtE':function(_0x513dd0,_0x5b7b1f){return _0x513dd0===_0x5b7b1f;},'igsAb':function(_0x4d9cf2,_0x2e6729){return _0x4d9cf2===_0x2e6729;},'bjqRR':function(_0x64b24c,_0xb8b0be){return _0x64b24c===_0xb8b0be;},'eRUmh':function(_0x1ac561,_0x5444d2){return _0x1ac561===_0x5444d2;},'maQHE':function(_0x19f862,_0x4272ec){return _0x19f862===_0x4272ec;},'VlOOq':_0xb10e(0x13),'AKPsC':function(_0x564ed0,_0x43e166){return _0x564ed0===_0x43e166;},'bBFjH':function(_0xa62353,_0x41f600){return _0xa62353===_0x41f600;},'AGGTO':function(_0x3ceb88,_0x1d4cba){return _0x3ceb88===_0x1d4cba;},'rAUbp':function(_0x512c45,_0x257655){return _0x512c45===_0x257655;},'WMTis':function(_0x1fa440,_0x3d69d4){return _0x1fa440<_0x3d69d4;},'oaCBw':function(_0x4dceae,_0x4eec83){return _0x4dceae!==_0x4eec83;},'Iskwt':_0xb10e(0x14),'zXNKg':function(_0x1f198e,_0x5b9172){return _0x1f198e-_0x5b9172;},'xNTry':_0xb10e(0x15),'HBheE':'medium_term','QWcln':_0xb10e(0x16),'MmXoA':_0xb10e(0x17),'yEDOr':'An\x20unknown\x20error\x20occurred\x20during\x20data\x20storage.','CszHf':_0xb10e(0x18),'CzVvp':_0xb10e(0x19)},_0x9b8658=async(_0x20d0da,_0x180f25)=>{const _0x285676={'pPqWp':_0xf204b[_0xb10e(0x1a)],'XujaG':_0xf204b[_0xb10e(0x1b)],'xUeLS':_0xf204b['dURFj'],'CqZqJ':_0xf204b[_0xb10e(0x1c)],'KjJzv':_0xb10e(0x1d),'YxFyF':_0xf204b['lZMxH']};var _0x1840e3,_0x2dde4c,_0x167e2b,_0x2f949d,_0x4936b2,_0x287b77,_0x5f169b,_0x41ae2e,_0x53e342;console[_0xb10e(0x1e)](_0xf204b[_0xb10e(0x1f)]),console['log'](_0xf204b[_0xb10e(0x20)],_0x20d0da),console[_0xb10e(0x1e)](_0xf204b[_0xb10e(0x21)],_0x180f25[_0xb10e(0x22)]);if(!_0x20d0da)return _0xf204b['VVXyK'](_0xf204b[_0xb10e(0x23)],_0xf204b[_0xb10e(0x24)])?(_0x10804d[_0xb10e(0x1e)](_0x285676['pPqWp']),!![]):(console[_0xb10e(0x25)](_0xf204b[_0xb10e(0x26)]),_reactNative[_0xb10e(0x27)][_0xb10e(0x28)](_0xf204b[_0xb10e(0x29)],_0xf204b[_0xb10e(0x2a)],[{'text':'OK','style':_0xf204b[_0xb10e(0x2b)]}]),![]);const _0x2dcd13=_0xf204b['RJsOQ'](_0xf204b[_0xb10e(0x2c)](_0xf204b[_0xb10e(0x2d)](_0xf204b[_0xb10e(0x2e)]((_0xf204b[_0xb10e(0x2f)](_0x1840e3=_0x180f25[_0xb10e(0x30)],null)||_0xf204b['xFxMd'](_0x1840e3,void 0x0)||_0xf204b[_0xb10e(0x31)](_0x1840e3=_0x1840e3[_0xb10e(0x32)],null)||_0xf204b[_0xb10e(0x33)](_0x1840e3,void 0x0)?void 0x0:_0x1840e3[_0xb10e(0x34)])||0x0,(_0xf204b[_0xb10e(0x35)](_0x2dde4c=_0x180f25['topItems'],null)||_0xf204b['xFxMd'](_0x2dde4c,void 0x0)||_0xf204b[_0xb10e(0x36)](_0x2dde4c=_0x2dde4c[_0xb10e(0x37)],null)||_0xf204b[_0xb10e(0x2f)](_0x2dde4c,void 0x0)?void 0x0:_0x2dde4c[_0xb10e(0x34)])||0x0),(_0xf204b['VVXyK'](_0x167e2b=_0x180f25[_0xb10e(0x38)],null)||_0xf204b[_0xb10e(0x35)](_0x167e2b,void 0x0)||(_0x167e2b=_0x167e2b[_0xb10e(0x39)])===null||_0xf204b[_0xb10e(0x36)](_0x167e2b,void 0x0)?void 0x0:_0x167e2b[_0xb10e(0x34)])||0x0)+((_0xf204b[_0xb10e(0x2f)](_0x2f949d=_0x180f25[_0xb10e(0x3a)],null)||_0xf204b[_0xb10e(0x33)](_0x2f949d,void 0x0)?void 0x0:_0x2f949d[_0xb10e(0x34)])||0x0),(_0xf204b[_0xb10e(0x3b)](_0x4936b2=_0x180f25[_0xb10e(0x3c)],null)||_0xf204b['igsAb'](_0x4936b2,void 0x0)?void 0x0:_0x4936b2[_0xb10e(0x34)])||0x0),(_0xf204b[_0xb10e(0x31)](_0x287b77=_0x180f25[_0xb10e(0x3d)],null)||_0xf204b[_0xb10e(0x3e)](_0x287b77,void 0x0)?void 0x0:_0x287b77[_0xb10e(0x34)])||0x0);if(_0xf204b[_0xb10e(0x3f)](_0x2dcd13,0x0)){if(_0xb10e(0x40)!==_0xf204b[_0xb10e(0x41)])return console['log'](_0xb10e(0x7)),!![];else{const _0x59f3ea=_0x4d1f0a[_0xb10e(0x42)]&&_0x3bc09f[_0xb10e(0x43)];return!_0x59f3ea&&_0x3f6819[_0xb10e(0x44)](_0xf204b[_0xb10e(0x45)],_0x2cc195),_0x59f3ea;}}const _0x196a46=(((_0x5f169b=_0x180f25[_0xb10e(0x30)])===null||_0xf204b[_0xb10e(0x46)](_0x5f169b,void 0x0)?void 0x0:_0x5f169b[_0xb10e(0x32)])||[])[_0xb10e(0x47)](_0x1c5bdd=>{const _0x13c310=_0x1c5bdd[_0xb10e(0x42)]&&_0x1c5bdd[_0xb10e(0x43)];return!_0x13c310&&(_0xf204b['NyUgM']!==_0xb10e(0x3)?_0x5ec883[_0xb10e(0x44)](_0x285676[_0xb10e(0x48)],_0x53254b):console[_0xb10e(0x44)](_0xf204b['VQnwW'],_0x1c5bdd)),_0x13c310;}),_0x83314f=((_0xf204b[_0xb10e(0x49)](_0x41ae2e=_0x180f25[_0xb10e(0x38)],null)||_0xf204b['VVXyK'](_0x41ae2e,void 0x0)?void 0x0:_0x41ae2e[_0xb10e(0x37)])||[])[_0xb10e(0x47)](_0x1b1f04=>{const _0x56ec83=_0x1b1f04[_0xb10e(0x42)]&&_0x1b1f04[_0xb10e(0x43)];return!_0x56ec83&&console[_0xb10e(0x44)](_0x285676[_0xb10e(0x48)],_0x1b1f04),_0x56ec83;}),_0x6dc309=((_0xf204b[_0xb10e(0x4a)](_0x53e342=_0x180f25[_0xb10e(0x38)],null)||_0xf204b[_0xb10e(0x4b)](_0x53e342,void 0x0)?void 0x0:_0x53e342[_0xb10e(0x39)])||[])[_0xb10e(0x47)](_0x2976bc=>{if(_0xf204b[_0xb10e(0x33)](_0xf204b['Mcgna'],_0xf204b[_0xb10e(0x4c)]))return _0x574e4a['error'](_0x285676['xUeLS'],_0x2c391f['error']),_0x58c08e[_0xb10e(0x27)]['alert'](_0x285676[_0xb10e(0x4d)],_0x55927f[_0xb10e(0x25)]||_0x285676['KjJzv'],[{'text':'OK','style':_0xb10e(0x12)}]),![];else{const _0x5a111f=_0x2976bc[_0xb10e(0x4e)]&&_0x2976bc[_0xb10e(0x43)];return!_0x5a111f&&console[_0xb10e(0x44)](_0xb10e(0x4f),_0x2976bc),_0x5a111f;}}),_0x267dda=(_0x180f25[_0xb10e(0x3a)]||[])[_0xb10e(0x47)](_0x5180b7=>{const _0x3a35fd=_0x5180b7['playlistId']&&_0x5180b7[_0xb10e(0x43)];if(!_0x3a35fd){if(_0xf204b[_0xb10e(0x50)](_0xb10e(0x51),_0xb10e(0x52)))console[_0xb10e(0x44)](_0xf204b[_0xb10e(0x53)],_0x5180b7);else{const _0x51921d=_0x45bc16[_0xb10e(0x42)]&&_0x1b549c[_0xb10e(0x43)];return!_0x51921d&&_0x5007a5[_0xb10e(0x44)]('â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20top\x20track:',_0x2fbbee),_0x51921d;}}return _0x3a35fd;}),_0x179e5b=(_0x180f25[_0xb10e(0x3c)]||[])[_0xb10e(0x47)](_0x255a53=>{const _0x23d8d9=_0x255a53['trackId']&&_0x255a53[_0xb10e(0x43)];return!_0x23d8d9&&console[_0xb10e(0x44)](_0x285676[_0xb10e(0x54)],_0x255a53),_0x23d8d9;}),_0x140302=(_0x180f25[_0xb10e(0x3d)]||[])[_0xb10e(0x47)](_0x52faf4=>{const _0x1d958e=_0x52faf4[_0xb10e(0x55)]&&_0x52faf4['name'];return!_0x1d958e&&console[_0xb10e(0x44)](_0xf204b[_0xb10e(0x56)],_0x52faf4),_0x1d958e;}),_0x4a20e6=_0x2dcd13,_0x5cc0e4=_0xf204b[_0xb10e(0x2e)](_0xf204b[_0xb10e(0x2c)](_0xf204b[_0xb10e(0x2c)](_0x196a46[_0xb10e(0x34)],_0x83314f[_0xb10e(0x34)]),_0x6dc309[_0xb10e(0x34)])+_0x267dda[_0xb10e(0x34)]+_0x179e5b[_0xb10e(0x34)],_0x140302[_0xb10e(0x34)]);if(_0xf204b['WMTis'](_0x5cc0e4,_0x4a20e6)){if(_0xf204b[_0xb10e(0x57)](_0xf204b['Iskwt'],_0xf204b[_0xb10e(0x58)])){const _0x1cecc5=_0x3b9874[_0xb10e(0x55)]&&_0x45ff8b[_0xb10e(0x43)];return!_0x1cecc5&&_0xb309c['warn'](_0xf204b[_0xb10e(0x56)],_0x1617cb),_0x1cecc5;}else console[_0xb10e(0x44)](_0xb10e(0x59)+_0xf204b['zXNKg'](_0x4a20e6,_0x5cc0e4)+_0xb10e(0x5a));}try{var _0x56b9d5;console[_0xb10e(0x1e)](_0xf204b[_0xb10e(0x5b)]);const _0x734041=await(0x0,_spotifyDataService[_0xb10e(0x5c)])(_0x20d0da,{'recentlyPlayed':{'items':_0x196a46,'totalCount':_0x196a46[_0xb10e(0x34)]},'topItems':{'tracks':_0x83314f,'artists':_0x6dc309,'timeRange':(_0xf204b['rAUbp'](_0x56b9d5=_0x180f25['topItems'],null)||_0x56b9d5===void 0x0?void 0x0:_0x56b9d5[_0xb10e(0x5d)])||_0xf204b[_0xb10e(0x5e)]},'playlists':_0x267dda,'savedTracks':_0x179e5b,'savedAlbums':_0x140302,'profile':_0x180f25[_0xb10e(0x5f)],'tokenExpiry':_0x180f25[_0xb10e(0x60)],'userId':_0x180f25[_0xb10e(0x61)]});return _0x734041['success']?(console[_0xb10e(0x1e)](_0xf204b[_0xb10e(0x62)]),console['log'](_0xf204b['MmXoA'],_0x734041['data']),!![]):(console['error'](_0xf204b[_0xb10e(0x63)],_0x734041[_0xb10e(0x25)]),_reactNative['Alert']['alert'](_0xf204b[_0xb10e(0x1c)],_0x734041[_0xb10e(0x25)]||_0xf204b[_0xb10e(0x64)],[{'text':'OK','style':_0xf204b['jlCCw']}]),![]);}catch(_0x238507){return console[_0xb10e(0x25)](_0xf204b[_0xb10e(0x65)],_0x238507),_reactNative[_0xb10e(0x27)][_0xb10e(0x28)](_0xf204b[_0xb10e(0x66)],_0xb10e(0x67),[{'text':'OK','style':_0xf204b[_0xb10e(0x2b)]}]),![];}};return{'initiateDataExport':_0x9b8658};};exports[_0xb10e(0x68)]=useSpotifyDataExtractor;function _0x16f9(){const _0xeca936=['defineProperty','__esModule','â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20saved\x20track:','VwyJl','FXmcv','â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20playlist:','â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20saved\x20album:','âšī¸\x20[SPOTIFY_EXTRACTOR]\x20No\x20data\x20to\x20export\x20-\x20treating\x20as\x20success\x20(connected)','â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20top\x20track:','â\x20[SPOTIFY_EXTRACTOR]\x20Backend\x20storage\x20failed:','Export\x20Failed','đ\x20[SPOTIFY_EXTRACTOR]\x20Initiating\x20data\x20export','đ¤\x20[SPOTIFY_EXTRACTOR]\x20Username:','đ\x20[SPOTIFY_EXTRACTOR]\x20Summary:','vAxQv','BmCkz','â\x20[SPOTIFY_EXTRACTOR]\x20Username\x20is\x20required','Username\x20is\x20required\x20to\x20export\x20Spotify\x20data.','default','tQcwL','jyRTR','đĄ\x20[SPOTIFY_EXTRACTOR]\x20Sending\x20to\x20backend...','â
\x20[SPOTIFY_EXTRACTOR]\x20Export\x20completed\x20successfully','đ\x20[SPOTIFY_EXTRACTOR]\x20Backend\x20response:','â\x20[SPOTIFY_EXTRACTOR]\x20Unexpected\x20error\x20during\x20export:','Export\x20Error','XhkLn','gVObB','kAuDS','An\x20unknown\x20error\x20occurred\x20during\x20data\x20storage.','log','URsBm','GLtIZ','jjNso','summary','aZTuJ','viHFb','error','tMoUe','Alert','alert','vnusH','OvMJC','jlCCw','qplLM','RJsOQ','WvcjD','EBdSr','recentlyPlayed','VVXyK','items','xFxMd','length','OjTtE','igsAb','tracks','topItems','artists','playlists','bjqRR','savedTracks','savedAlbums','eRUmh','maQHE','MHZHX','VlOOq','trackId','name','warn','lZMxH','AKPsC','filter','XujaG','bBFjH','AGGTO','rAUbp','GKsoV','CqZqJ','artistId','â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Invalid\x20top\x20artist:','bKxHB','pCxJu','wXiPr','oxUre','YxFyF','albumId','yeHTU','oaCBw','Iskwt','â ī¸\x20[SPOTIFY_EXTRACTOR]\x20Filtered\x20out\x20','\x20invalid\x20items','xNTry','storeSpotifyData','timeRange','HBheE','profile','tokenExpiry','userId','QWcln','dURFj','yEDOr','CszHf','CzVvp','Failed\x20to\x20connect\x20to\x20the\x20data\x20storage\x20service.\x20Please\x20check\x20your\x20network\x20connection.','useSpotifyDataExtractor'];_0x16f9=function(){return _0xeca936;};return _0x16f9();}
|
|
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
|