ugcinc 2.5.0 → 2.5.1
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/render.d.ts +9 -7
- package/dist/render.js +34 -9
- package/package.json +1 -1
package/dist/render.d.ts
CHANGED
|
@@ -56,21 +56,23 @@ export declare class RenderClient extends BaseClient {
|
|
|
56
56
|
* if (status.data.status === 'completed') {
|
|
57
57
|
* console.log('Output type:', status.data.output_type); // 'video' or 'image'
|
|
58
58
|
* console.log('Download URL:', status.data.download_url);
|
|
59
|
-
* // Use the download_url to get the file (video or image)
|
|
60
59
|
* }
|
|
61
60
|
* ```
|
|
62
61
|
*/
|
|
63
62
|
getStatus(jobId: string): Promise<ApiResponse<RenderJobStatus>>;
|
|
64
63
|
/**
|
|
65
|
-
*
|
|
64
|
+
* Download the rendered file (video or image)
|
|
66
65
|
* @param jobId - The job ID
|
|
67
|
-
* @returns
|
|
66
|
+
* @returns The rendered file as a blob
|
|
68
67
|
* @example
|
|
69
68
|
* ```typescript
|
|
70
|
-
* const
|
|
71
|
-
*
|
|
72
|
-
*
|
|
69
|
+
* const file = await client.render.download(jobId);
|
|
70
|
+
* if (file.ok) {
|
|
71
|
+
* // Create download link
|
|
72
|
+
* const url = URL.createObjectURL(file.data);
|
|
73
|
+
* window.location.href = url;
|
|
74
|
+
* }
|
|
73
75
|
* ```
|
|
74
76
|
*/
|
|
75
|
-
|
|
77
|
+
download(jobId: string): Promise<ApiResponse<Blob>>;
|
|
76
78
|
}
|
package/dist/render.js
CHANGED
|
@@ -64,26 +64,51 @@ class RenderClient extends base_1.BaseClient {
|
|
|
64
64
|
* if (status.data.status === 'completed') {
|
|
65
65
|
* console.log('Output type:', status.data.output_type); // 'video' or 'image'
|
|
66
66
|
* console.log('Download URL:', status.data.download_url);
|
|
67
|
-
* // Use the download_url to get the file (video or image)
|
|
68
67
|
* }
|
|
69
68
|
* ```
|
|
70
69
|
*/
|
|
71
70
|
async getStatus(jobId) {
|
|
72
|
-
return this.
|
|
71
|
+
return this.post('/render/status', { job_id: jobId });
|
|
73
72
|
}
|
|
74
73
|
/**
|
|
75
|
-
*
|
|
74
|
+
* Download the rendered file (video or image)
|
|
76
75
|
* @param jobId - The job ID
|
|
77
|
-
* @returns
|
|
76
|
+
* @returns The rendered file as a blob
|
|
78
77
|
* @example
|
|
79
78
|
* ```typescript
|
|
80
|
-
* const
|
|
81
|
-
*
|
|
82
|
-
*
|
|
79
|
+
* const file = await client.render.download(jobId);
|
|
80
|
+
* if (file.ok) {
|
|
81
|
+
* // Create download link
|
|
82
|
+
* const url = URL.createObjectURL(file.data);
|
|
83
|
+
* window.location.href = url;
|
|
84
|
+
* }
|
|
83
85
|
* ```
|
|
84
86
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
async download(jobId) {
|
|
88
|
+
const response = await fetch(`${this['baseUrl']}/render/download`, {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
headers: {
|
|
91
|
+
'Authorization': this.orgId ? '' : `Bearer ${this.apiKey}`,
|
|
92
|
+
'x-api-key': this.orgId ? this.apiKey : '',
|
|
93
|
+
'Content-Type': 'application/json',
|
|
94
|
+
},
|
|
95
|
+
body: JSON.stringify({ job_id: jobId })
|
|
96
|
+
});
|
|
97
|
+
if (!response.ok) {
|
|
98
|
+
const errorData = await response.json().catch(() => ({ message: 'Download failed' }));
|
|
99
|
+
return {
|
|
100
|
+
ok: false,
|
|
101
|
+
code: response.status,
|
|
102
|
+
message: errorData.message || 'Failed to download file'
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const blob = await response.blob();
|
|
106
|
+
return {
|
|
107
|
+
ok: true,
|
|
108
|
+
code: 200,
|
|
109
|
+
message: 'Success',
|
|
110
|
+
data: blob
|
|
111
|
+
};
|
|
87
112
|
}
|
|
88
113
|
}
|
|
89
114
|
exports.RenderClient = RenderClient;
|