@umituz/react-native-ai-pruna-provider 1.0.29 → 1.0.30
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-pruna-provider",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.30",
|
|
4
4
|
"description": "Pruna AI provider for React Native - implements IAIProvider interface for unified AI generation",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -105,6 +105,18 @@ export async function uploadFileToStorage(
|
|
|
105
105
|
const timeoutId = setTimeout(() => uploadController.abort(), UPLOAD_CONFIG.timeoutMs);
|
|
106
106
|
|
|
107
107
|
try {
|
|
108
|
+
// __DEV__ log request details
|
|
109
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
110
|
+
console.log(`[DEV] [${TAG}] Sending upload request:`, {
|
|
111
|
+
url: PRUNA_FILES_URL,
|
|
112
|
+
method: 'POST',
|
|
113
|
+
headers: {
|
|
114
|
+
'apikey': apiKey.substring(0, 15) + '...',
|
|
115
|
+
},
|
|
116
|
+
formDataKeys: Array.from(formData.keys()),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
108
120
|
const uploadResponse = await fetch(PRUNA_FILES_URL, {
|
|
109
121
|
method: 'POST',
|
|
110
122
|
headers: { 'apikey': apiKey },
|
|
@@ -113,9 +125,51 @@ export async function uploadFileToStorage(
|
|
|
113
125
|
});
|
|
114
126
|
|
|
115
127
|
if (!uploadResponse.ok) {
|
|
116
|
-
|
|
117
|
-
const
|
|
128
|
+
// Get response details for debugging
|
|
129
|
+
const statusText = uploadResponse.statusText;
|
|
130
|
+
const status = uploadResponse.status;
|
|
131
|
+
|
|
132
|
+
// Try to get error details from response
|
|
133
|
+
let rawBody = '';
|
|
134
|
+
let errorDetails: Record<string, unknown> = {};
|
|
135
|
+
|
|
136
|
+
try {
|
|
137
|
+
rawBody = await uploadResponse.text();
|
|
138
|
+
if (rawBody) {
|
|
139
|
+
try {
|
|
140
|
+
errorDetails = JSON.parse(rawBody) as Record<string, unknown>;
|
|
141
|
+
} catch {
|
|
142
|
+
// If not JSON, keep raw text
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
} catch {
|
|
146
|
+
// If reading body fails, continue with status info
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const errorMessage = (errorDetails as { message?: string; detail?: string; error?: string }).message ||
|
|
150
|
+
(errorDetails as { detail?: string }).detail ||
|
|
151
|
+
(errorDetails as { error?: string }).error ||
|
|
152
|
+
rawBody ||
|
|
153
|
+
`File upload error: ${status}`;
|
|
154
|
+
|
|
118
155
|
generationLogCollector.error(sessionId, TAG, `File upload failed: ${errorMessage}`);
|
|
156
|
+
|
|
157
|
+
// __DEV__ detailed error logging
|
|
158
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
159
|
+
console.error(`[DEV] [${TAG}] File upload FAILED:`, {
|
|
160
|
+
status,
|
|
161
|
+
statusText,
|
|
162
|
+
errorMessage,
|
|
163
|
+
rawBody: rawBody.substring(0, 1000),
|
|
164
|
+
errorDetails,
|
|
165
|
+
url: PRUNA_FILES_URL,
|
|
166
|
+
formDataPreview: {
|
|
167
|
+
hasContent: formData.has('content'),
|
|
168
|
+
contentType: formData.get('content')?.toString().substring(0, 100) + '...',
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
119
173
|
throw new Error(errorMessage);
|
|
120
174
|
}
|
|
121
175
|
|
|
@@ -125,6 +179,17 @@ export async function uploadFileToStorage(
|
|
|
125
179
|
const elapsed = Date.now() - startTime;
|
|
126
180
|
generationLogCollector.log(sessionId, TAG, `File upload completed in ${elapsed}ms → ${fileUrl}`);
|
|
127
181
|
|
|
182
|
+
// __DEV__ log response details
|
|
183
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
184
|
+
console.log(`[DEV] [${TAG}] File upload SUCCESS:`, {
|
|
185
|
+
elapsedMs: elapsed,
|
|
186
|
+
fileId: data.id,
|
|
187
|
+
fileUrl,
|
|
188
|
+
urls: data.urls,
|
|
189
|
+
responseKeys: Object.keys(data),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
128
193
|
return fileUrl;
|
|
129
194
|
} catch (error) {
|
|
130
195
|
if (error instanceof Error && error.name === 'AbortError') {
|