magic-hour 0.41.0 → 0.43.0

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.
Files changed (48) hide show
  1. package/README.md +1 -0
  2. package/dist/environment.d.ts +1 -1
  3. package/dist/environment.js +1 -1
  4. package/dist/helpers/generate-type.d.ts +1 -1
  5. package/dist/resources/v1/ai-gif-generator/resource-client.d.ts +1 -1
  6. package/dist/resources/v1/ai-gif-generator/resource-client.js +1 -1
  7. package/dist/resources/v1/ai-headshot-generator/resource-client.d.ts +1 -1
  8. package/dist/resources/v1/ai-headshot-generator/resource-client.js +1 -1
  9. package/dist/resources/v1/ai-image-editor/resource-client.d.ts +12 -2
  10. package/dist/resources/v1/ai-image-editor/resource-client.js +13 -7
  11. package/dist/resources/v1/ai-image-generator/resource-client.d.ts +2 -2
  12. package/dist/resources/v1/ai-image-generator/resource-client.js +2 -2
  13. package/dist/resources/v1/ai-qr-code-generator/resource-client.d.ts +2 -2
  14. package/dist/resources/v1/ai-qr-code-generator/resource-client.js +2 -2
  15. package/dist/resources/v1/ai-voice-generator/resource-client.d.ts +29 -0
  16. package/dist/resources/v1/ai-voice-generator/resource-client.js +60 -0
  17. package/dist/resources/v1/audio-projects/resource-client.d.ts +23 -1
  18. package/dist/resources/v1/audio-projects/resource-client.js +68 -0
  19. package/dist/resources/v1/audio-projects/resource-client.test.d.ts +1 -0
  20. package/dist/resources/v1/audio-projects/resource-client.test.js +552 -0
  21. package/dist/resources/v1/face-swap/resource-client.d.ts +1 -1
  22. package/dist/resources/v1/face-swap/resource-client.js +1 -1
  23. package/dist/resources/v1/files/upload-urls/resource-client.d.ts +3 -2
  24. package/dist/resources/v1/files/upload-urls/resource-client.js +3 -2
  25. package/dist/types/index.d.ts +2 -0
  26. package/dist/types/v1-ai-image-editor-create-body-assets.d.ts +13 -3
  27. package/dist/types/v1-ai-image-editor-create-body-assets.js +6 -2
  28. package/dist/types/v1-ai-image-editor-create-body-style-model-enum.d.ts +6 -0
  29. package/dist/types/v1-ai-image-editor-create-body-style-model-enum.js +2 -0
  30. package/dist/types/v1-ai-image-editor-create-body-style.d.ts +7 -0
  31. package/dist/types/v1-ai-image-editor-create-body-style.js +4 -0
  32. package/dist/types/v1-ai-image-generator-create-body-style-quality-mode-enum.d.ts +10 -0
  33. package/dist/types/v1-ai-image-generator-create-body-style-quality-mode-enum.js +2 -0
  34. package/dist/types/v1-ai-image-generator-create-body-style.d.ts +11 -0
  35. package/dist/types/v1-ai-image-generator-create-body-style.js +4 -0
  36. package/dist/types/v1-ai-voice-generator-create-body-style-voice-name-enum.d.ts +2 -2
  37. package/dist/types/v1-ai-voice-generator-create-body-style.d.ts +4 -4
  38. package/dist/types/v1-ai-voice-generator-create-body-style.js +380 -0
  39. package/dist/types/v1-audio-projects-get-response.d.ts +1 -1
  40. package/dist/types/v1-face-swap-create-body-style-version-enum.d.ts +1 -1
  41. package/dist/types/v1-face-swap-create-body-style.d.ts +1 -1
  42. package/dist/types/v1-files-upload-urls-create-body-items-item.d.ts +1 -1
  43. package/dist/types/v1-video-projects-get-response.d.ts +1 -1
  44. package/dist/types/v1-video-to-video-create-body-style-art-style-enum.d.ts +1 -1
  45. package/dist/types/v1-video-to-video-create-body-style-model-enum.d.ts +1 -1
  46. package/dist/types/v1-video-to-video-create-body-style.d.ts +4 -4
  47. package/dist/types/v1-video-to-video-create-body-style.js +34 -2
  48. package/package.json +1 -1
@@ -0,0 +1,552 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const magic_hour_1 = __importDefault(require("../../../index.js"));
16
+ const node_1 = require("msw/node");
17
+ const msw_1 = require("msw");
18
+ // Create MSW server
19
+ const server = (0, node_1.setupServer)();
20
+ // Mock the sleep helper
21
+ jest.mock("magic-hour/helpers/sleep", () => ({
22
+ sleep: jest.fn().mockResolvedValue(undefined),
23
+ }));
24
+ // Mock the download helper
25
+ jest.mock("magic-hour/helpers/download", () => ({
26
+ downloadFiles: jest.fn(),
27
+ }));
28
+ const { sleep } = require("../../../helpers/sleep");
29
+ const { downloadFiles } = require("../../../helpers/download");
30
+ describe("AudioProjectsClient.checkResult", () => {
31
+ let client;
32
+ beforeAll(() => {
33
+ // Start MSW server
34
+ server.listen();
35
+ });
36
+ afterAll(() => {
37
+ // Stop MSW server
38
+ server.close();
39
+ });
40
+ beforeEach(() => {
41
+ client = new magic_hour_1.default({
42
+ token: "API_TOKEN",
43
+ });
44
+ // Reset all mocks
45
+ jest.clearAllMocks();
46
+ // Reset MSW handlers
47
+ server.resetHandlers();
48
+ // Clean up environment variables
49
+ delete process.env["MAGIC_HOUR_POLL_INTERVAL"];
50
+ });
51
+ describe("Basic functionality", () => {
52
+ test("should return response without waiting when waitForCompletion is false", () => __awaiter(void 0, void 0, void 0, function* () {
53
+ const mockResponse = {
54
+ id: "audio-123",
55
+ status: "rendering",
56
+ created_at: "2024-01-01T00:00:00Z",
57
+ credits_charged: 2,
58
+ downloads: [],
59
+ enabled: true,
60
+ error: null,
61
+ name: "Test Audio Project",
62
+ type: "VOICE_GENERATOR",
63
+ };
64
+ // Set up MSW handler for the API call
65
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
66
+ return msw_1.HttpResponse.json(mockResponse);
67
+ }));
68
+ const result = yield client.v1.audioProjects.checkResult({ id: "audio-123" }, { waitForCompletion: false });
69
+ expect(result).toEqual({
70
+ id: "audio-123",
71
+ status: "rendering",
72
+ createdAt: "2024-01-01T00:00:00Z",
73
+ creditsCharged: 2,
74
+ downloads: [],
75
+ enabled: true,
76
+ error: null,
77
+ name: "Test Audio Project",
78
+ type: "VOICE_GENERATOR",
79
+ });
80
+ expect(sleep).not.toHaveBeenCalled();
81
+ }));
82
+ test("should wait for completion and return successful result", () => __awaiter(void 0, void 0, void 0, function* () {
83
+ const renderingResponse = {
84
+ id: "audio-123",
85
+ status: "rendering",
86
+ created_at: "2024-01-01T00:00:00Z",
87
+ credits_charged: 2,
88
+ downloads: [],
89
+ enabled: true,
90
+ error: null,
91
+ name: "Test Audio Project",
92
+ type: "VOICE_GENERATOR",
93
+ };
94
+ const completeResponse = {
95
+ id: "audio-123",
96
+ status: "complete",
97
+ created_at: "2024-01-01T00:00:00Z",
98
+ credits_charged: 2,
99
+ downloads: [
100
+ {
101
+ url: "https://example.com/download/audio1.wav",
102
+ expires_at: "2024-01-01T01:00:00Z",
103
+ },
104
+ ],
105
+ enabled: true,
106
+ error: null,
107
+ name: "Test Audio Project",
108
+ type: "VOICE_GENERATOR",
109
+ };
110
+ let callCount = 0;
111
+ // Set up MSW handler that returns different responses on each call
112
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
113
+ callCount++;
114
+ if (callCount === 1) {
115
+ return msw_1.HttpResponse.json(renderingResponse);
116
+ }
117
+ else {
118
+ return msw_1.HttpResponse.json(completeResponse);
119
+ }
120
+ }));
121
+ downloadFiles.mockResolvedValue(["/tmp/audio1.wav"]);
122
+ const result = yield client.v1.audioProjects.checkResult({ id: "audio-123" }, {
123
+ waitForCompletion: true,
124
+ downloadOutputs: true,
125
+ downloadDirectory: "/tmp",
126
+ });
127
+ expect(result).toEqual({
128
+ id: "audio-123",
129
+ status: "complete",
130
+ createdAt: "2024-01-01T00:00:00Z",
131
+ creditsCharged: 2,
132
+ downloads: [
133
+ {
134
+ url: "https://example.com/download/audio1.wav",
135
+ expiresAt: "2024-01-01T01:00:00Z",
136
+ },
137
+ ],
138
+ enabled: true,
139
+ error: null,
140
+ name: "Test Audio Project",
141
+ type: "VOICE_GENERATOR",
142
+ downloadedPaths: ["/tmp/audio1.wav"],
143
+ });
144
+ expect(sleep).toHaveBeenCalledWith(500); // Default poll interval
145
+ expect(downloadFiles).toHaveBeenCalledWith([
146
+ {
147
+ url: "https://example.com/download/audio1.wav",
148
+ expiresAt: "2024-01-01T01:00:00Z",
149
+ },
150
+ ], "/tmp");
151
+ }));
152
+ test("should handle error status during polling", () => __awaiter(void 0, void 0, void 0, function* () {
153
+ const renderingResponse = {
154
+ id: "audio-123",
155
+ status: "rendering",
156
+ created_at: "2024-01-01T00:00:00Z",
157
+ credits_charged: 2,
158
+ downloads: [],
159
+ enabled: true,
160
+ error: null,
161
+ name: "Test Audio Project",
162
+ type: "VOICE_GENERATOR",
163
+ };
164
+ const errorResponse = {
165
+ id: "audio-123",
166
+ status: "error",
167
+ created_at: "2024-01-01T00:00:00Z",
168
+ credits_charged: 2,
169
+ downloads: [],
170
+ enabled: true,
171
+ error: { message: "Rendering failed", code: "ERROR_001" },
172
+ name: "Test Audio Project",
173
+ type: "VOICE_GENERATOR",
174
+ };
175
+ let callCount = 0;
176
+ // Set up MSW handler that returns different responses on each call
177
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
178
+ callCount++;
179
+ if (callCount === 1) {
180
+ return msw_1.HttpResponse.json(renderingResponse);
181
+ }
182
+ else {
183
+ return msw_1.HttpResponse.json(errorResponse);
184
+ }
185
+ }));
186
+ const result = yield client.v1.audioProjects.checkResult({ id: "audio-123" }, { waitForCompletion: true });
187
+ expect(result).toEqual({
188
+ id: "audio-123",
189
+ status: "error",
190
+ createdAt: "2024-01-01T00:00:00Z",
191
+ creditsCharged: 2,
192
+ downloads: [],
193
+ enabled: true,
194
+ error: { message: "Rendering failed", code: "ERROR_001" },
195
+ name: "Test Audio Project",
196
+ type: "VOICE_GENERATOR",
197
+ });
198
+ }));
199
+ test("should handle canceled status during polling", () => __awaiter(void 0, void 0, void 0, function* () {
200
+ const renderingResponse = {
201
+ id: "audio-123",
202
+ status: "rendering",
203
+ created_at: "2024-01-01T00:00:00Z",
204
+ credits_charged: 2,
205
+ downloads: [],
206
+ enabled: true,
207
+ error: null,
208
+ name: "Test Audio Project",
209
+ type: "VOICE_GENERATOR",
210
+ };
211
+ const canceledResponse = {
212
+ id: "audio-123",
213
+ status: "canceled",
214
+ created_at: "2024-01-01T00:00:00Z",
215
+ credits_charged: 2,
216
+ downloads: [],
217
+ enabled: true,
218
+ error: null,
219
+ name: "Test Audio Project",
220
+ type: "VOICE_GENERATOR",
221
+ };
222
+ let callCount = 0;
223
+ // Set up MSW handler that returns different responses on each call
224
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
225
+ callCount++;
226
+ if (callCount === 1) {
227
+ return msw_1.HttpResponse.json(renderingResponse);
228
+ }
229
+ else {
230
+ return msw_1.HttpResponse.json(canceledResponse);
231
+ }
232
+ }));
233
+ const result = yield client.v1.audioProjects.checkResult({ id: "audio-123" }, { waitForCompletion: true });
234
+ expect(result).toEqual({
235
+ id: "audio-123",
236
+ status: "canceled",
237
+ createdAt: "2024-01-01T00:00:00Z",
238
+ creditsCharged: 2,
239
+ downloads: [],
240
+ enabled: true,
241
+ error: null,
242
+ name: "Test Audio Project",
243
+ type: "VOICE_GENERATOR",
244
+ });
245
+ }));
246
+ });
247
+ describe("Polling behavior", () => {
248
+ test("should use custom poll interval from environment", () => __awaiter(void 0, void 0, void 0, function* () {
249
+ const renderingResponse = {
250
+ id: "audio-123",
251
+ status: "rendering",
252
+ created_at: "2024-01-01T00:00:00Z",
253
+ credits_charged: 2,
254
+ downloads: [],
255
+ enabled: true,
256
+ error: null,
257
+ name: "Test Audio Project",
258
+ type: "VOICE_GENERATOR",
259
+ };
260
+ const completeResponse = {
261
+ id: "audio-123",
262
+ status: "complete",
263
+ created_at: "2024-01-01T00:00:00Z",
264
+ credits_charged: 2,
265
+ downloads: [],
266
+ enabled: true,
267
+ error: null,
268
+ name: "Test Audio Project",
269
+ type: "VOICE_GENERATOR",
270
+ };
271
+ let callCount = 0;
272
+ // Set up MSW handler that returns different responses on each call
273
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
274
+ callCount++;
275
+ if (callCount === 1) {
276
+ return msw_1.HttpResponse.json(renderingResponse);
277
+ }
278
+ else {
279
+ return msw_1.HttpResponse.json(completeResponse);
280
+ }
281
+ }));
282
+ // Set environment variable before the checkResult call
283
+ process.env["MAGIC_HOUR_POLL_INTERVAL"] = "1.5";
284
+ try {
285
+ yield client.v1.audioProjects.checkResult({ id: "audio-123" });
286
+ expect(sleep).toHaveBeenCalledWith(1500); // 1.5 seconds converted to milliseconds
287
+ }
288
+ finally {
289
+ // Clean up environment variable
290
+ delete process.env["MAGIC_HOUR_POLL_INTERVAL"];
291
+ }
292
+ }));
293
+ test("should poll multiple times until completion", () => __awaiter(void 0, void 0, void 0, function* () {
294
+ const renderingResponse = {
295
+ id: "audio-123",
296
+ status: "rendering",
297
+ created_at: "2024-01-01T00:00:00Z",
298
+ credits_charged: 2,
299
+ downloads: [],
300
+ enabled: true,
301
+ error: null,
302
+ name: "Test Audio Project",
303
+ type: "VOICE_GENERATOR",
304
+ };
305
+ const queuedResponse = Object.assign(Object.assign({}, renderingResponse), { status: "queued" });
306
+ const completeResponse = Object.assign(Object.assign({}, renderingResponse), { status: "complete" });
307
+ let callCount = 0;
308
+ // Set up MSW handler that returns different responses on each call
309
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
310
+ callCount++;
311
+ if (callCount === 1) {
312
+ return msw_1.HttpResponse.json(renderingResponse);
313
+ }
314
+ else if (callCount === 2) {
315
+ return msw_1.HttpResponse.json(queuedResponse);
316
+ }
317
+ else {
318
+ return msw_1.HttpResponse.json(completeResponse);
319
+ }
320
+ }));
321
+ yield client.v1.audioProjects.checkResult({ id: "audio-123" });
322
+ expect(sleep).toHaveBeenCalledTimes(2);
323
+ }));
324
+ });
325
+ describe("Download functionality", () => {
326
+ test("should skip download when downloadOutputs is false", () => __awaiter(void 0, void 0, void 0, function* () {
327
+ const completeResponse = {
328
+ id: "audio-123",
329
+ status: "complete",
330
+ created_at: "2024-01-01T00:00:00Z",
331
+ credits_charged: 2,
332
+ downloads: [
333
+ {
334
+ url: "https://example.com/download/audio1.wav",
335
+ expires_at: "2024-01-01T01:00:00Z",
336
+ },
337
+ ],
338
+ enabled: true,
339
+ error: null,
340
+ name: "Test Audio Project",
341
+ type: "VOICE_GENERATOR",
342
+ };
343
+ // Set up MSW handler
344
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
345
+ return msw_1.HttpResponse.json(completeResponse);
346
+ }));
347
+ const result = yield client.v1.audioProjects.checkResult({ id: "audio-123" }, {
348
+ waitForCompletion: true,
349
+ downloadOutputs: false,
350
+ });
351
+ expect(result).toEqual({
352
+ id: "audio-123",
353
+ status: "complete",
354
+ createdAt: "2024-01-01T00:00:00Z",
355
+ creditsCharged: 2,
356
+ downloads: [
357
+ {
358
+ url: "https://example.com/download/audio1.wav",
359
+ expiresAt: "2024-01-01T01:00:00Z",
360
+ },
361
+ ],
362
+ enabled: true,
363
+ error: null,
364
+ name: "Test Audio Project",
365
+ type: "VOICE_GENERATOR",
366
+ });
367
+ expect(downloadFiles).not.toHaveBeenCalled();
368
+ }));
369
+ test("should download files to current directory when no downloadDirectory specified", () => __awaiter(void 0, void 0, void 0, function* () {
370
+ const completeResponse = {
371
+ id: "audio-123",
372
+ status: "complete",
373
+ created_at: "2024-01-01T00:00:00Z",
374
+ credits_charged: 2,
375
+ downloads: [
376
+ {
377
+ url: "https://example.com/download/audio1.wav",
378
+ expires_at: "2024-01-01T01:00:00Z",
379
+ },
380
+ ],
381
+ enabled: true,
382
+ error: null,
383
+ name: "Test Audio Project",
384
+ type: "VOICE_GENERATOR",
385
+ };
386
+ // Set up MSW handler
387
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
388
+ return msw_1.HttpResponse.json(completeResponse);
389
+ }));
390
+ downloadFiles.mockResolvedValue(["/current/dir/audio1.wav"]);
391
+ const result = yield client.v1.audioProjects.checkResult({ id: "audio-123" }, { downloadOutputs: true });
392
+ expect(downloadFiles).toHaveBeenCalledWith([
393
+ {
394
+ url: "https://example.com/download/audio1.wav",
395
+ expiresAt: "2024-01-01T01:00:00Z",
396
+ },
397
+ ], undefined);
398
+ expect(result.downloadedPaths).toEqual(["/current/dir/audio1.wav"]);
399
+ }));
400
+ test("should handle download errors gracefully", () => __awaiter(void 0, void 0, void 0, function* () {
401
+ const completeResponse = {
402
+ id: "audio-123",
403
+ status: "complete",
404
+ created_at: "2024-01-01T00:00:00Z",
405
+ credits_charged: 2,
406
+ downloads: [
407
+ {
408
+ url: "https://example.com/download/audio1.wav",
409
+ expires_at: "2024-01-01T01:00:00Z",
410
+ },
411
+ ],
412
+ enabled: true,
413
+ error: null,
414
+ name: "Test Audio Project",
415
+ type: "VOICE_GENERATOR",
416
+ };
417
+ // Set up MSW handler
418
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
419
+ return msw_1.HttpResponse.json(completeResponse);
420
+ }));
421
+ downloadFiles.mockRejectedValue(new Error("Download failed"));
422
+ yield expect(client.v1.audioProjects.checkResult({ id: "audio-123" }, { downloadOutputs: true })).rejects.toThrow("Download failed");
423
+ }));
424
+ });
425
+ describe("Default behavior", () => {
426
+ test("should use default options when no options provided", () => __awaiter(void 0, void 0, void 0, function* () {
427
+ const completeResponse = {
428
+ id: "audio-123",
429
+ status: "complete",
430
+ created_at: "2024-01-01T00:00:00Z",
431
+ credits_charged: 2,
432
+ downloads: [
433
+ {
434
+ url: "https://example.com/download/audio1.wav",
435
+ expires_at: "2024-01-01T01:00:00Z",
436
+ },
437
+ ],
438
+ enabled: true,
439
+ error: null,
440
+ name: "Test Audio Project",
441
+ type: "VOICE_GENERATOR",
442
+ };
443
+ const renderingResponse = Object.assign(Object.assign({}, completeResponse), { status: "rendering" });
444
+ let callCount = 0;
445
+ // Set up MSW handler that returns different responses on each call
446
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
447
+ callCount++;
448
+ if (callCount === 1) {
449
+ return msw_1.HttpResponse.json(renderingResponse);
450
+ }
451
+ else {
452
+ return msw_1.HttpResponse.json(completeResponse);
453
+ }
454
+ }));
455
+ downloadFiles.mockResolvedValue(["/tmp/audio1.wav"]);
456
+ const result = yield client.v1.audioProjects.checkResult({
457
+ id: "audio-123",
458
+ });
459
+ expect(result.downloadedPaths).toEqual(["/tmp/audio1.wav"]);
460
+ expect(sleep).toHaveBeenCalledWith(500); // Default poll interval
461
+ }));
462
+ });
463
+ describe("Request options", () => {
464
+ test("should pass additional request options to get method", () => __awaiter(void 0, void 0, void 0, function* () {
465
+ const mockResponse = {
466
+ id: "audio-123",
467
+ status: "complete",
468
+ created_at: "2024-01-01T00:00:00Z",
469
+ credits_charged: 2,
470
+ downloads: [],
471
+ enabled: true,
472
+ error: null,
473
+ name: "Test Audio Project",
474
+ type: "VOICE_GENERATOR",
475
+ };
476
+ // Set up MSW handler
477
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
478
+ return msw_1.HttpResponse.json(mockResponse);
479
+ }));
480
+ const getMock = jest.spyOn(client.v1.audioProjects, "get");
481
+ yield client.v1.audioProjects.checkResult({ id: "audio-123" }, {
482
+ waitForCompletion: false,
483
+ timeout: 30000,
484
+ });
485
+ expect(getMock).toHaveBeenCalledWith({ id: "audio-123" }, {
486
+ timeout: 30000,
487
+ });
488
+ }));
489
+ });
490
+ describe("Edge cases", () => {
491
+ test("should handle immediate completion without polling", () => __awaiter(void 0, void 0, void 0, function* () {
492
+ const completeResponse = {
493
+ id: "audio-123",
494
+ status: "complete",
495
+ created_at: "2024-01-01T00:00:00Z",
496
+ credits_charged: 2,
497
+ downloads: [],
498
+ enabled: true,
499
+ error: null,
500
+ name: "Test Audio Project",
501
+ type: "VOICE_GENERATOR",
502
+ };
503
+ // Set up MSW handler
504
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
505
+ return msw_1.HttpResponse.json(completeResponse);
506
+ }));
507
+ const result = yield client.v1.audioProjects.checkResult({ id: "audio-123" }, { waitForCompletion: false });
508
+ expect(result).toEqual({
509
+ id: "audio-123",
510
+ status: "complete",
511
+ createdAt: "2024-01-01T00:00:00Z",
512
+ creditsCharged: 2,
513
+ downloads: [],
514
+ enabled: true,
515
+ error: null,
516
+ name: "Test Audio Project",
517
+ type: "VOICE_GENERATOR",
518
+ });
519
+ expect(sleep).not.toHaveBeenCalled();
520
+ expect(downloadFiles).not.toHaveBeenCalled();
521
+ }));
522
+ test("should handle empty downloads array", () => __awaiter(void 0, void 0, void 0, function* () {
523
+ const completeResponse = {
524
+ id: "audio-123",
525
+ status: "complete",
526
+ created_at: "2024-01-01T00:00:00Z",
527
+ credits_charged: 2,
528
+ downloads: [],
529
+ enabled: true,
530
+ error: null,
531
+ name: "Test Audio Project",
532
+ type: "VOICE_GENERATOR",
533
+ };
534
+ // Set up MSW handler
535
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
536
+ return msw_1.HttpResponse.json(completeResponse);
537
+ }));
538
+ downloadFiles.mockResolvedValue([]);
539
+ const result = yield client.v1.audioProjects.checkResult({ id: "audio-123" }, { downloadOutputs: true });
540
+ expect(result.downloadedPaths).toEqual([]);
541
+ expect(downloadFiles).toHaveBeenCalledWith([], undefined);
542
+ }));
543
+ test("should handle get method throwing error", () => __awaiter(void 0, void 0, void 0, function* () {
544
+ const error = new Error("API Error");
545
+ // Set up MSW handler that returns an error
546
+ server.use(msw_1.http.get("https://api.magichour.ai/v1/audio-projects/audio-123", () => {
547
+ return msw_1.HttpResponse.json({ error: "API Error" }, { status: 500 });
548
+ }));
549
+ yield expect(client.v1.audioProjects.checkResult({ id: "audio-123" })).rejects.toThrow();
550
+ }));
551
+ });
552
+ });
@@ -80,7 +80,7 @@ export declare class FaceSwapClient extends CoreResourceClient {
80
80
  */
81
81
  generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../video-projects/resource-client").V1VideoProjectsGetResponseWithDownloads>;
82
82
  /**
83
- * Face Swap video
83
+ * Face Swap Video
84
84
  *
85
85
  * Create a Face Swap video. The estimated frame cost is calculated using 30 FPS. This amount is deducted from your account balance when a video is queued. Once the video is complete, the cost will be updated based on the actual number of frames rendered.
86
86
  *
@@ -134,7 +134,7 @@ class FaceSwapClient extends make_api_request_js_1.CoreResourceClient {
134
134
  });
135
135
  }
136
136
  /**
137
- * Face Swap video
137
+ * Face Swap Video
138
138
  *
139
139
  * Create a Face Swap video. The estimated frame cost is calculated using 30 FPS. This amount is deducted from your account balance when a video is queued. Once the video is complete, the cost will be updated based on the actual number of frames rendered.
140
140
  *
@@ -12,8 +12,9 @@ export declare class UploadUrlsClient extends CoreResourceClient {
12
12
  *
13
13
  * **Valid file extensions per asset type**:
14
14
  * - video: mp4, m4v, mov, webm
15
- * - audio: mp3, mpeg, wav, aac, aiff, flac
16
- * - image: png, jpg, jpeg, webp, avif, jp2, tiff, bmp
15
+ * - audio: mp3, wav, aac, flac, webm
16
+ * - image: png, jpg, jpeg, heic, webp, avif, jp2, tiff, bmp
17
+ * - gif: gif, webp, webm
17
18
  *
18
19
  * > Note: `gif` is only supported for face swap API `video_file_path` field.
19
20
  *
@@ -17,8 +17,9 @@ class UploadUrlsClient extends make_api_request_js_1.CoreResourceClient {
17
17
  *
18
18
  * **Valid file extensions per asset type**:
19
19
  * - video: mp4, m4v, mov, webm
20
- * - audio: mp3, mpeg, wav, aac, aiff, flac
21
- * - image: png, jpg, jpeg, webp, avif, jp2, tiff, bmp
20
+ * - audio: mp3, wav, aac, flac, webm
21
+ * - image: png, jpg, jpeg, heic, webp, avif, jp2, tiff, bmp
22
+ * - gif: gif, webp, webm
22
23
  *
23
24
  * > Note: `gif` is only supported for face swap API `video_file_path` field.
24
25
  *
@@ -17,10 +17,12 @@ export { V1AiHeadshotGeneratorCreateResponse } from "./v1-ai-headshot-generator-
17
17
  export { V1AiImageEditorCreateBody } from "./v1-ai-image-editor-create-body";
18
18
  export { V1AiImageEditorCreateBodyAssets } from "./v1-ai-image-editor-create-body-assets";
19
19
  export { V1AiImageEditorCreateBodyStyle } from "./v1-ai-image-editor-create-body-style";
20
+ export { V1AiImageEditorCreateBodyStyleModelEnum } from "./v1-ai-image-editor-create-body-style-model-enum";
20
21
  export { V1AiImageEditorCreateResponse } from "./v1-ai-image-editor-create-response";
21
22
  export { V1AiImageGeneratorCreateBody } from "./v1-ai-image-generator-create-body";
22
23
  export { V1AiImageGeneratorCreateBodyOrientationEnum } from "./v1-ai-image-generator-create-body-orientation-enum";
23
24
  export { V1AiImageGeneratorCreateBodyStyle } from "./v1-ai-image-generator-create-body-style";
25
+ export { V1AiImageGeneratorCreateBodyStyleQualityModeEnum } from "./v1-ai-image-generator-create-body-style-quality-mode-enum";
24
26
  export { V1AiImageGeneratorCreateBodyStyleToolEnum } from "./v1-ai-image-generator-create-body-style-tool-enum";
25
27
  export { V1AiImageGeneratorCreateResponse } from "./v1-ai-image-generator-create-response";
26
28
  export { V1AiImageUpscalerCreateBody } from "./v1-ai-image-upscaler-create-body";
@@ -4,14 +4,23 @@ import * as z from "zod";
4
4
  */
5
5
  export type V1AiImageEditorCreateBodyAssets = {
6
6
  /**
7
- * The image used in the edit. This value is either
7
+ * Deprecated: Please use `image_file_paths` instead as edits with multiple images are now supported. The image used in the edit. This value is either
8
8
  * - a direct URL to the video file
9
9
  * - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls).
10
10
  *
11
11
  * Please refer to the [Input File documentation](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) to learn more.
12
12
  *
13
13
  */
14
- imageFilePath: string;
14
+ imageFilePath?: string | undefined;
15
+ /**
16
+ * The image(s) used in the edit, maximum of 10 images. This value is either
17
+ * - a direct URL to the video file
18
+ * - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls).
19
+ *
20
+ * Please refer to the [Input File documentation](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) to learn more.
21
+ *
22
+ */
23
+ imageFilePaths?: string[] | undefined;
15
24
  };
16
25
  /**
17
26
  * @internal
@@ -19,7 +28,8 @@ export type V1AiImageEditorCreateBodyAssets = {
19
28
  * we expect to come in as network data
20
29
  */
21
30
  export type External$V1AiImageEditorCreateBodyAssets = {
22
- image_file_path: string;
31
+ image_file_path?: string | undefined;
32
+ image_file_paths?: string[] | undefined;
23
33
  };
24
34
  export declare const Schemas$V1AiImageEditorCreateBodyAssets: {
25
35
  in: z.ZodType<V1AiImageEditorCreateBodyAssets, z.ZodTypeDef, unknown>;
@@ -41,11 +41,13 @@ const z = __importStar(require("zod"));
41
41
  */
42
42
  const SchemaIn$V1AiImageEditorCreateBodyAssets = z
43
43
  .object({
44
- image_file_path: z.string(),
44
+ image_file_path: z.string().optional(),
45
+ image_file_paths: z.array(z.string()).optional(),
45
46
  })
46
47
  .transform((obj) => {
47
48
  return (0, make_api_request_js_1.zodTransform)(obj, {
48
49
  image_file_path: "imageFilePath",
50
+ image_file_paths: "imageFilePaths",
49
51
  });
50
52
  });
51
53
  /**
@@ -54,11 +56,13 @@ const SchemaIn$V1AiImageEditorCreateBodyAssets = z
54
56
  */
55
57
  const SchemaOut$V1AiImageEditorCreateBodyAssets = z
56
58
  .object({
57
- imageFilePath: z.string(),
59
+ imageFilePath: z.string().optional(),
60
+ imageFilePaths: z.array(z.string()).optional(),
58
61
  })
59
62
  .transform((obj) => {
60
63
  return (0, make_api_request_js_1.zodTransform)(obj, {
61
64
  imageFilePath: "image_file_path",
65
+ imageFilePaths: "image_file_paths",
62
66
  });
63
67
  });
64
68
  exports.Schemas$V1AiImageEditorCreateBodyAssets = {