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 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
- * Get the download URL for a completed render job
64
+ * Download the rendered file (video or image)
66
65
  * @param jobId - The job ID
67
- * @returns Download URL that can be used to fetch the file (video or image)
66
+ * @returns The rendered file as a blob
68
67
  * @example
69
68
  * ```typescript
70
- * const url = client.render.getDownloadUrl(jobId);
71
- * // Use this URL in an <a> tag or to download the file
72
- * window.location.href = url;
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
- getDownloadUrl(jobId: string): string;
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.get(`/render/status?job_id=${jobId}`);
71
+ return this.post('/render/status', { job_id: jobId });
73
72
  }
74
73
  /**
75
- * Get the download URL for a completed render job
74
+ * Download the rendered file (video or image)
76
75
  * @param jobId - The job ID
77
- * @returns Download URL that can be used to fetch the file (video or image)
76
+ * @returns The rendered file as a blob
78
77
  * @example
79
78
  * ```typescript
80
- * const url = client.render.getDownloadUrl(jobId);
81
- * // Use this URL in an <a> tag or to download the file
82
- * window.location.href = url;
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
- getDownloadUrl(jobId) {
86
- return `https://api.ugc.inc/render/download?job_id=${jobId}`;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugcinc",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "TypeScript/JavaScript client for the UGC Inc API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",