@umituz/react-native-ai-pruna-provider 1.0.28 → 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",
|
|
@@ -74,8 +74,6 @@ export async function uploadFileToStorage(
|
|
|
74
74
|
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
75
75
|
console.log(`[DEV] [${TAG}] Data URI upload:`, {
|
|
76
76
|
mimeType,
|
|
77
|
-
extension,
|
|
78
|
-
filename,
|
|
79
77
|
base64Length: rawBase64.length,
|
|
80
78
|
dataUriPrefix: dataUri.substring(0, 50) + '...',
|
|
81
79
|
});
|
|
@@ -107,6 +105,18 @@ export async function uploadFileToStorage(
|
|
|
107
105
|
const timeoutId = setTimeout(() => uploadController.abort(), UPLOAD_CONFIG.timeoutMs);
|
|
108
106
|
|
|
109
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
|
+
|
|
110
120
|
const uploadResponse = await fetch(PRUNA_FILES_URL, {
|
|
111
121
|
method: 'POST',
|
|
112
122
|
headers: { 'apikey': apiKey },
|
|
@@ -115,9 +125,51 @@ export async function uploadFileToStorage(
|
|
|
115
125
|
});
|
|
116
126
|
|
|
117
127
|
if (!uploadResponse.ok) {
|
|
118
|
-
|
|
119
|
-
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
|
+
|
|
120
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
|
+
|
|
121
173
|
throw new Error(errorMessage);
|
|
122
174
|
}
|
|
123
175
|
|
|
@@ -127,6 +179,17 @@ export async function uploadFileToStorage(
|
|
|
127
179
|
const elapsed = Date.now() - startTime;
|
|
128
180
|
generationLogCollector.log(sessionId, TAG, `File upload completed in ${elapsed}ms → ${fileUrl}`);
|
|
129
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
|
+
|
|
130
193
|
return fileUrl;
|
|
131
194
|
} catch (error) {
|
|
132
195
|
if (error instanceof Error && error.name === 'AbortError') {
|