@golpoai/sdk 0.1.9 → 0.1.10

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.cjs CHANGED
@@ -110,13 +110,11 @@ var Golpo = class {
110
110
  async createPodcast(prompt, opts = {}) {
111
111
  const { pollIntervalMs = 2e3, ...jobOpts } = opts;
112
112
  const jobId = await this.createPodcastJob(prompt, jobOpts);
113
- return this.pollUntilComplete(
113
+ const r = await this.pollUntilComplete(
114
114
  jobId,
115
115
  pollIntervalMs
116
- ).then((r) => ({
117
- podcastUrl: r.podcast_url,
118
- podcastScript: r.podcast_script
119
- }));
116
+ );
117
+ return { url: r.podcast_url, script: r.podcast_script, videoId: jobId };
120
118
  }
121
119
  async createVideo(prompt, opts = {}) {
122
120
  const {
@@ -160,13 +158,11 @@ var Golpo = class {
160
158
  timeout: 24e4,
161
159
  headers: formData.getHeaders()
162
160
  });
163
- return this.pollUntilComplete(
161
+ const r = await this.pollUntilComplete(
164
162
  data.job_id,
165
163
  pollIntervalMs
166
- ).then((r) => ({
167
- videoUrl: r.podcast_url,
168
- videoScript: r.podcast_script
169
- }));
164
+ );
165
+ return { url: r.podcast_url, script: r.podcast_script, videoId: data.job_id };
170
166
  }
171
167
  /**
172
168
  * Edit specific frames of a video and regenerate the video.
@@ -213,11 +209,11 @@ var Golpo = class {
213
209
  try {
214
210
  const frameVersions = await this.getFrameVersions(videoId);
215
211
  let frameAnimations = frameVersions.frame_animations ? { ...frameVersions.frame_animations } : {};
216
- frameIds.forEach(async (frameId) => {
212
+ for (const frameId of frameIds) {
217
213
  await this.setFrameVersion(videoId, frameId, editResult);
218
214
  const updatedVersions = await this.getFrameVersions(videoId);
219
215
  frameAnimations = updatedVersions.frame_animations || {};
220
- });
216
+ }
221
217
  const mp4Urls = Object.entries(frameAnimations).sort(([a], [b]) => parseInt(a) - parseInt(b)).map(([_, url]) => url);
222
218
  if (mp4Urls.length === 0) {
223
219
  throw new Error("No frame animations found to combine");
@@ -227,17 +223,11 @@ var Golpo = class {
227
223
  pollIntervalMs,
228
224
  videoUrl
229
225
  };
230
- const combinedUrl = await this.combineVideos(combineOptions);
231
- return {
232
- videoUrl: combinedUrl,
233
- jobId
234
- };
226
+ const combined = await this.combineVideos(combineOptions);
227
+ return { videoUrl: combined.url, jobId };
235
228
  } catch (error) {
236
229
  console.warn("Failed to auto-combine videos, returning edit result:", error);
237
- return {
238
- videoUrl: editResult,
239
- jobId
240
- };
230
+ return { videoUrl: editResult, jobId };
241
231
  }
242
232
  }
243
233
  /**
@@ -391,7 +381,8 @@ var Golpo = class {
391
381
  if (!combineJobId) {
392
382
  throw new Error("No job ID received from combine-videos API");
393
383
  }
394
- return this.pollEditStatus(combineJobId, pollIntervalMs);
384
+ const url = await this.pollEditStatus(combineJobId, pollIntervalMs);
385
+ return { url };
395
386
  }
396
387
  /* ------------------------------------------------------------ *
397
388
  * INTERNAL HELPERS
package/dist/index.d.cts CHANGED
@@ -41,11 +41,35 @@ interface EditVideoOptions {
41
41
  pollIntervalMs?: number;
42
42
  autoCombine?: boolean;
43
43
  }
44
+ interface FrameAnimations {
45
+ [frameId: string]: string;
46
+ }
44
47
  interface CombineVideosOptions {
45
48
  mp4Urls: string[];
46
49
  videoUrl?: string;
47
50
  pollIntervalMs?: number;
48
51
  }
52
+ /**
53
+ * Result of createPodcast or createVideo (generated content URL, script, and job ID).
54
+ */
55
+ interface GenerationResult {
56
+ url: string;
57
+ script: string;
58
+ videoId: string;
59
+ }
60
+ /**
61
+ * Result of editVideo (edited or combined video URL and job ID).
62
+ */
63
+ interface VideoEditResult {
64
+ videoUrl: string;
65
+ jobId: string;
66
+ }
67
+ /**
68
+ * Result of combineVideos (URL of the combined video).
69
+ */
70
+ interface CombinedVideoResult {
71
+ url: string;
72
+ }
49
73
  declare class Golpo {
50
74
  private readonly http;
51
75
  constructor(apiKey: string, baseUrl?: string);
@@ -57,23 +81,14 @@ declare class Golpo {
57
81
  podcastUrl: string;
58
82
  podcastScript: string;
59
83
  }>;
60
- createPodcast(prompt: string, opts?: CreatePodcastOptions): Promise<{
61
- podcastUrl: string;
62
- podcastScript: string;
63
- }>;
64
- createVideo(prompt: string, opts?: CreateVideoOptions): Promise<{
65
- videoUrl: string;
66
- videoScript: string;
67
- }>;
84
+ createPodcast(prompt: string, opts?: CreatePodcastOptions): Promise<GenerationResult>;
85
+ createVideo(prompt: string, opts?: CreateVideoOptions): Promise<GenerationResult>;
68
86
  /**
69
87
  * Edit specific frames of a video and regenerate the video.
70
88
  * This method polls until completion and returns the final edited video URL.
71
89
  * If autoCombine is true, it will also combine all frames into a final video.
72
90
  */
73
- editVideo(videoId: string, opts: EditVideoOptions): Promise<{
74
- videoUrl: string;
75
- jobId: string;
76
- }>;
91
+ editVideo(videoId: string, opts: EditVideoOptions): Promise<VideoEditResult>;
77
92
  /**
78
93
  * Combines edited frames into a final video with audio.
79
94
  * This is a helper method used by editVideo when autoCombine is enabled.
@@ -99,7 +114,7 @@ declare class Golpo {
99
114
  * Returns a dictionary mapping frame indices to animation URLs.
100
115
  * This is a convenience method that extracts frame_animations from getFrameVersions.
101
116
  */
102
- private getFrameAnimations;
117
+ getFrameAnimations(videoId: string): Promise<FrameAnimations>;
103
118
  /**
104
119
  * Get frame versions and animations for a video.
105
120
  * Returns both the current frame_animations and available frame_animation_versions.
@@ -114,10 +129,10 @@ declare class Golpo {
114
129
  * Combine multiple MP4 videos into a single video.
115
130
  * This is used to combine frame animations into a final video.
116
131
  */
117
- combineVideos(opts: CombineVideosOptions): Promise<string>;
132
+ combineVideos(opts: CombineVideosOptions): Promise<CombinedVideoResult>;
118
133
  private pollUntilComplete;
119
134
  private pollEditStatus;
120
135
  private createFormData;
121
136
  }
122
137
 
123
- export { type CombineVideosOptions, type CreatePodcastOptions, type CreateVideoOptions, type EditVideoOptions, Golpo, Golpo as default };
138
+ export { type CombineVideosOptions, type CombinedVideoResult, type CreatePodcastOptions, type CreateVideoOptions, type EditVideoOptions, type GenerationResult, Golpo, type VideoEditResult, Golpo as default };
package/dist/index.d.ts CHANGED
@@ -41,11 +41,35 @@ interface EditVideoOptions {
41
41
  pollIntervalMs?: number;
42
42
  autoCombine?: boolean;
43
43
  }
44
+ interface FrameAnimations {
45
+ [frameId: string]: string;
46
+ }
44
47
  interface CombineVideosOptions {
45
48
  mp4Urls: string[];
46
49
  videoUrl?: string;
47
50
  pollIntervalMs?: number;
48
51
  }
52
+ /**
53
+ * Result of createPodcast or createVideo (generated content URL, script, and job ID).
54
+ */
55
+ interface GenerationResult {
56
+ url: string;
57
+ script: string;
58
+ videoId: string;
59
+ }
60
+ /**
61
+ * Result of editVideo (edited or combined video URL and job ID).
62
+ */
63
+ interface VideoEditResult {
64
+ videoUrl: string;
65
+ jobId: string;
66
+ }
67
+ /**
68
+ * Result of combineVideos (URL of the combined video).
69
+ */
70
+ interface CombinedVideoResult {
71
+ url: string;
72
+ }
49
73
  declare class Golpo {
50
74
  private readonly http;
51
75
  constructor(apiKey: string, baseUrl?: string);
@@ -57,23 +81,14 @@ declare class Golpo {
57
81
  podcastUrl: string;
58
82
  podcastScript: string;
59
83
  }>;
60
- createPodcast(prompt: string, opts?: CreatePodcastOptions): Promise<{
61
- podcastUrl: string;
62
- podcastScript: string;
63
- }>;
64
- createVideo(prompt: string, opts?: CreateVideoOptions): Promise<{
65
- videoUrl: string;
66
- videoScript: string;
67
- }>;
84
+ createPodcast(prompt: string, opts?: CreatePodcastOptions): Promise<GenerationResult>;
85
+ createVideo(prompt: string, opts?: CreateVideoOptions): Promise<GenerationResult>;
68
86
  /**
69
87
  * Edit specific frames of a video and regenerate the video.
70
88
  * This method polls until completion and returns the final edited video URL.
71
89
  * If autoCombine is true, it will also combine all frames into a final video.
72
90
  */
73
- editVideo(videoId: string, opts: EditVideoOptions): Promise<{
74
- videoUrl: string;
75
- jobId: string;
76
- }>;
91
+ editVideo(videoId: string, opts: EditVideoOptions): Promise<VideoEditResult>;
77
92
  /**
78
93
  * Combines edited frames into a final video with audio.
79
94
  * This is a helper method used by editVideo when autoCombine is enabled.
@@ -99,7 +114,7 @@ declare class Golpo {
99
114
  * Returns a dictionary mapping frame indices to animation URLs.
100
115
  * This is a convenience method that extracts frame_animations from getFrameVersions.
101
116
  */
102
- private getFrameAnimations;
117
+ getFrameAnimations(videoId: string): Promise<FrameAnimations>;
103
118
  /**
104
119
  * Get frame versions and animations for a video.
105
120
  * Returns both the current frame_animations and available frame_animation_versions.
@@ -114,10 +129,10 @@ declare class Golpo {
114
129
  * Combine multiple MP4 videos into a single video.
115
130
  * This is used to combine frame animations into a final video.
116
131
  */
117
- combineVideos(opts: CombineVideosOptions): Promise<string>;
132
+ combineVideos(opts: CombineVideosOptions): Promise<CombinedVideoResult>;
118
133
  private pollUntilComplete;
119
134
  private pollEditStatus;
120
135
  private createFormData;
121
136
  }
122
137
 
123
- export { type CombineVideosOptions, type CreatePodcastOptions, type CreateVideoOptions, type EditVideoOptions, Golpo, Golpo as default };
138
+ export { type CombineVideosOptions, type CombinedVideoResult, type CreatePodcastOptions, type CreateVideoOptions, type EditVideoOptions, type GenerationResult, Golpo, type VideoEditResult, Golpo as default };
package/dist/index.js CHANGED
@@ -73,13 +73,11 @@ var Golpo = class {
73
73
  async createPodcast(prompt, opts = {}) {
74
74
  const { pollIntervalMs = 2e3, ...jobOpts } = opts;
75
75
  const jobId = await this.createPodcastJob(prompt, jobOpts);
76
- return this.pollUntilComplete(
76
+ const r = await this.pollUntilComplete(
77
77
  jobId,
78
78
  pollIntervalMs
79
- ).then((r) => ({
80
- podcastUrl: r.podcast_url,
81
- podcastScript: r.podcast_script
82
- }));
79
+ );
80
+ return { url: r.podcast_url, script: r.podcast_script, videoId: jobId };
83
81
  }
84
82
  async createVideo(prompt, opts = {}) {
85
83
  const {
@@ -123,13 +121,11 @@ var Golpo = class {
123
121
  timeout: 24e4,
124
122
  headers: formData.getHeaders()
125
123
  });
126
- return this.pollUntilComplete(
124
+ const r = await this.pollUntilComplete(
127
125
  data.job_id,
128
126
  pollIntervalMs
129
- ).then((r) => ({
130
- videoUrl: r.podcast_url,
131
- videoScript: r.podcast_script
132
- }));
127
+ );
128
+ return { url: r.podcast_url, script: r.podcast_script, videoId: data.job_id };
133
129
  }
134
130
  /**
135
131
  * Edit specific frames of a video and regenerate the video.
@@ -176,11 +172,11 @@ var Golpo = class {
176
172
  try {
177
173
  const frameVersions = await this.getFrameVersions(videoId);
178
174
  let frameAnimations = frameVersions.frame_animations ? { ...frameVersions.frame_animations } : {};
179
- frameIds.forEach(async (frameId) => {
175
+ for (const frameId of frameIds) {
180
176
  await this.setFrameVersion(videoId, frameId, editResult);
181
177
  const updatedVersions = await this.getFrameVersions(videoId);
182
178
  frameAnimations = updatedVersions.frame_animations || {};
183
- });
179
+ }
184
180
  const mp4Urls = Object.entries(frameAnimations).sort(([a], [b]) => parseInt(a) - parseInt(b)).map(([_, url]) => url);
185
181
  if (mp4Urls.length === 0) {
186
182
  throw new Error("No frame animations found to combine");
@@ -190,17 +186,11 @@ var Golpo = class {
190
186
  pollIntervalMs,
191
187
  videoUrl
192
188
  };
193
- const combinedUrl = await this.combineVideos(combineOptions);
194
- return {
195
- videoUrl: combinedUrl,
196
- jobId
197
- };
189
+ const combined = await this.combineVideos(combineOptions);
190
+ return { videoUrl: combined.url, jobId };
198
191
  } catch (error) {
199
192
  console.warn("Failed to auto-combine videos, returning edit result:", error);
200
- return {
201
- videoUrl: editResult,
202
- jobId
203
- };
193
+ return { videoUrl: editResult, jobId };
204
194
  }
205
195
  }
206
196
  /**
@@ -354,7 +344,8 @@ var Golpo = class {
354
344
  if (!combineJobId) {
355
345
  throw new Error("No job ID received from combine-videos API");
356
346
  }
357
- return this.pollEditStatus(combineJobId, pollIntervalMs);
347
+ const url = await this.pollEditStatus(combineJobId, pollIntervalMs);
348
+ return { url };
358
349
  }
359
350
  /* ------------------------------------------------------------ *
360
351
  * INTERNAL HELPERS
package/package.json CHANGED
@@ -1,8 +1,16 @@
1
1
  {
2
2
  "name": "@golpoai/sdk",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
- "exports": "./dist/index.js",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js",
9
+ "require": "./dist/index.cjs"
10
+ }
11
+ },
12
+ "main": "./dist/index.cjs",
13
+ "module": "./dist/index.js",
6
14
  "types": "./dist/index.d.ts",
7
15
  "files": [
8
16
  "dist/**/*"