wavespeed 0.0.5 → 0.0.6
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/dist/index.d.ts +21 -0
- package/dist/index.js +26 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,16 @@ export type PredictionStatus = 'created' | 'processing' | 'completed' | 'failed'
|
|
|
11
11
|
export interface PredictionUrls {
|
|
12
12
|
get: string;
|
|
13
13
|
}
|
|
14
|
+
export interface UploadFileResp {
|
|
15
|
+
code: number;
|
|
16
|
+
message: string;
|
|
17
|
+
data: {
|
|
18
|
+
type: string;
|
|
19
|
+
download_url: string;
|
|
20
|
+
filename: string;
|
|
21
|
+
size: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
14
24
|
/**
|
|
15
25
|
* Request options for fetch
|
|
16
26
|
*/
|
|
@@ -94,5 +104,16 @@ export declare class WaveSpeed {
|
|
|
94
104
|
* @param options Additional fetch options
|
|
95
105
|
*/
|
|
96
106
|
create(modelId: string, input: Record<string, any>, options?: RequestOptions): Promise<Prediction>;
|
|
107
|
+
/**
|
|
108
|
+
* Upload a file (binary) to the /media/upload/binary endpoint
|
|
109
|
+
* @param filePath Absolute path to the file to upload
|
|
110
|
+
* @returns The API response JSON
|
|
111
|
+
*/
|
|
112
|
+
/**
|
|
113
|
+
* Upload a file (binary) to the /media/upload/binary endpoint (browser Blob version)
|
|
114
|
+
* @param file Blob to upload
|
|
115
|
+
* @returns The API response JSON
|
|
116
|
+
*/
|
|
117
|
+
upload(file: Blob, options?: RequestOptions): Promise<string>;
|
|
97
118
|
}
|
|
98
119
|
export default WaveSpeed;
|
package/dist/index.js
CHANGED
|
@@ -218,6 +218,32 @@ class WaveSpeed {
|
|
|
218
218
|
}
|
|
219
219
|
return new Prediction(data.data, this);
|
|
220
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* Upload a file (binary) to the /media/upload/binary endpoint
|
|
223
|
+
* @param filePath Absolute path to the file to upload
|
|
224
|
+
* @returns The API response JSON
|
|
225
|
+
*/
|
|
226
|
+
/**
|
|
227
|
+
* Upload a file (binary) to the /media/upload/binary endpoint (browser Blob version)
|
|
228
|
+
* @param file Blob to upload
|
|
229
|
+
* @returns The API response JSON
|
|
230
|
+
*/
|
|
231
|
+
async upload(file, options) {
|
|
232
|
+
const form = new FormData();
|
|
233
|
+
form.append('file', file);
|
|
234
|
+
// Only set Authorization header; browser will set Content-Type
|
|
235
|
+
const response = await this.fetchWithTimeout('media/upload/binary', {
|
|
236
|
+
method: 'POST',
|
|
237
|
+
body: form,
|
|
238
|
+
...options
|
|
239
|
+
});
|
|
240
|
+
if (!response.ok) {
|
|
241
|
+
const errorText = await response.text();
|
|
242
|
+
throw new Error(`Failed to upload file: ${response.status} ${errorText}`);
|
|
243
|
+
}
|
|
244
|
+
const resp = await response.json();
|
|
245
|
+
return resp.data.download_url;
|
|
246
|
+
}
|
|
221
247
|
}
|
|
222
248
|
exports.WaveSpeed = WaveSpeed;
|
|
223
249
|
// Export default and named exports for different import styles
|