magic-hour 0.83.1 → 0.84.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.
- package/README.md +27 -0
- package/dist/environment.d.ts +1 -1
- package/dist/environment.js +1 -1
- package/dist/helpers/download-error.d.ts +16 -0
- package/dist/helpers/download-error.js +15 -0
- package/dist/helpers/download.js +22 -2
- package/dist/resources/v1/ai-talking-photo/request-types.d.ts +10 -1
- package/dist/resources/v1/ai-talking-photo/request-types.js +4 -0
- package/dist/resources/v1/ai-ugc-ad/index.d.ts +2 -0
- package/dist/resources/v1/ai-ugc-ad/index.js +5 -0
- package/dist/resources/v1/ai-ugc-ad/request-types.d.ts +50 -0
- package/dist/resources/v1/ai-ugc-ad/request-types.js +86 -0
- package/dist/resources/v1/ai-ugc-ad/resource-client.d.ts +41 -0
- package/dist/resources/v1/ai-ugc-ad/resource-client.js +81 -0
- package/dist/resources/v1/ai-video-editor/resource-client.d.ts +1 -1
- package/dist/resources/v1/ai-video-editor/resource-client.js +1 -1
- package/dist/resources/v1/ai-video-translator/resource-client.d.ts +1 -1
- package/dist/resources/v1/ai-video-translator/resource-client.js +1 -1
- package/dist/resources/v1/audio-projects/resource-client.d.ts +5 -0
- package/dist/resources/v1/audio-projects/resource-client.js +14 -2
- package/dist/resources/v1/audio-to-video/resource-client.d.ts +1 -1
- package/dist/resources/v1/audio-to-video/resource-client.js +1 -1
- package/dist/resources/v1/character-replace/resource-client.d.ts +1 -1
- package/dist/resources/v1/character-replace/resource-client.js +1 -1
- package/dist/resources/v1/face-detection/resource-client.d.ts +5 -0
- package/dist/resources/v1/face-detection/resource-client.js +17 -5
- package/dist/resources/v1/face-swap/resource-client.d.ts +1 -1
- package/dist/resources/v1/face-swap/resource-client.js +1 -1
- package/dist/resources/v1/image-projects/resource-client.d.ts +5 -0
- package/dist/resources/v1/image-projects/resource-client.js +14 -2
- package/dist/resources/v1/image-to-video/request-types.d.ts +6 -2
- package/dist/resources/v1/image-to-video/request-types.js +2 -0
- package/dist/resources/v1/image-to-video/resource-client.d.ts +1 -1
- package/dist/resources/v1/image-to-video/resource-client.js +1 -1
- package/dist/resources/v1/index.d.ts +1 -0
- package/dist/resources/v1/index.js +2 -1
- package/dist/resources/v1/lip-sync/resource-client.d.ts +1 -1
- package/dist/resources/v1/lip-sync/resource-client.js +1 -1
- package/dist/resources/v1/resource-client.d.ts +3 -0
- package/dist/resources/v1/resource-client.js +5 -0
- package/dist/resources/v1/text-to-video/request-types.d.ts +11 -3
- package/dist/resources/v1/text-to-video/request-types.js +2 -0
- package/dist/resources/v1/text-to-video/resource-client.d.ts +1 -1
- package/dist/resources/v1/text-to-video/resource-client.js +1 -1
- package/dist/resources/v1/video-projects/resource-client.d.ts +5 -0
- package/dist/resources/v1/video-projects/resource-client.js +14 -2
- package/dist/resources/v1/video-to-video/resource-client.d.ts +1 -1
- package/dist/resources/v1/video-to-video/resource-client.js +1 -1
- package/dist/types/index.d.ts +6 -0
- package/dist/types/v1-ai-talking-photo-create-body-resolution-enum.d.ts +4 -0
- package/dist/types/v1-ai-talking-photo-create-body-resolution-enum.js +2 -0
- package/dist/types/v1-ai-talking-photo-create-body.d.ts +10 -1
- package/dist/types/v1-ai-talking-photo-create-body.js +4 -0
- package/dist/types/v1-ai-ugc-ad-create-body-assets.d.ts +29 -0
- package/dist/types/v1-ai-ugc-ad-create-body-assets.js +69 -0
- package/dist/types/v1-ai-ugc-ad-create-body-model-enum.d.ts +4 -0
- package/dist/types/v1-ai-ugc-ad-create-body-model-enum.js +2 -0
- package/dist/types/v1-ai-ugc-ad-create-body-resolution-enum.d.ts +4 -0
- package/dist/types/v1-ai-ugc-ad-create-body-resolution-enum.js +2 -0
- package/dist/types/v1-ai-ugc-ad-create-body.d.ts +50 -0
- package/dist/types/v1-ai-ugc-ad-create-body.js +86 -0
- package/dist/types/v1-ai-ugc-ad-create-response.d.ts +36 -0
- package/dist/types/v1-ai-ugc-ad-create-response.js +75 -0
- package/dist/types/v1-image-to-video-create-body-assets.d.ts +2 -1
- package/dist/types/v1-image-to-video-create-body-model-enum.d.ts +2 -1
- package/dist/types/v1-image-to-video-create-body-resolution-enum.d.ts +1 -0
- package/dist/types/v1-image-to-video-create-body.d.ts +6 -2
- package/dist/types/v1-image-to-video-create-body.js +2 -0
- package/dist/types/v1-text-to-video-create-body-aspect-ratio-enum.d.ts +2 -1
- package/dist/types/v1-text-to-video-create-body-model-enum.d.ts +2 -1
- package/dist/types/v1-text-to-video-create-body-resolution-enum.d.ts +1 -0
- package/dist/types/v1-text-to-video-create-body.d.ts +11 -3
- package/dist/types/v1-text-to-video-create-body.js +2 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -89,6 +89,29 @@ console.log(`Status: ${response.status}`);
|
|
|
89
89
|
console.log(`Downloaded files: ${response.downloadedPaths}`);
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
+
### Recovering a local download failure
|
|
93
|
+
|
|
94
|
+
A completed generation remains complete if its files cannot be saved locally. The
|
|
95
|
+
result retains its project ID, status and remote download URLs; `downloadedPaths`
|
|
96
|
+
contains any files that were saved, and `downloadErrors` describes each directory
|
|
97
|
+
or file failure. A partial download therefore does not mean the generation failed.
|
|
98
|
+
|
|
99
|
+
Fix the local directory or network issue, then retry the existing project without
|
|
100
|
+
creating or paying for another generation:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
const recovered = await client.v1.imageProjects.checkResult(
|
|
104
|
+
{ id: response.id },
|
|
105
|
+
{ downloadDirectory: "./outputs" },
|
|
106
|
+
);
|
|
107
|
+
console.log(recovered.downloadedPaths, recovered.downloadErrors);
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Use `videoProjects` or `audioProjects` for those project types. The remote URLs
|
|
111
|
+
include expiration times: retrieve the same project again if you need current URLs.
|
|
112
|
+
Face detection returns the same local download errors alongside its face URLs;
|
|
113
|
+
retry those URLs directly rather than submitting another face detection task.
|
|
114
|
+
|
|
92
115
|
### Create Function
|
|
93
116
|
|
|
94
117
|
The `create()` function provides granular control:
|
|
@@ -255,6 +278,10 @@ Valid values are: `none`, `error`, `warn`, `info`, `debug` (case insensitive). I
|
|
|
255
278
|
- [create](src/resources/v1/ai-talking-photo/README.md#create) - AI Talking Photo
|
|
256
279
|
- [generate](src/resources/v1/ai-talking-photo/README.md#generate) - AI Talking Photo Generate Workflow
|
|
257
280
|
|
|
281
|
+
### [v1.aiUgcAd](src/resources/v1/ai-ugc-ad/README.md)
|
|
282
|
+
|
|
283
|
+
- [create](src/resources/v1/ai-ugc-ad/README.md#create) - AI UGC Ad Generator
|
|
284
|
+
|
|
258
285
|
### [v1.aiVideoEditor](src/resources/v1/ai-video-editor/README.md)
|
|
259
286
|
|
|
260
287
|
- [create](src/resources/v1/ai-video-editor/README.md#create) - AI Video Editor
|
package/dist/environment.d.ts
CHANGED
package/dist/environment.js
CHANGED
|
@@ -4,5 +4,5 @@ exports.Environment = void 0;
|
|
|
4
4
|
var Environment;
|
|
5
5
|
(function (Environment) {
|
|
6
6
|
Environment["Environment"] = "https://api.magichour.ai";
|
|
7
|
-
Environment["MockServer"] = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.
|
|
7
|
+
Environment["MockServer"] = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.88.0";
|
|
8
8
|
})(Environment || (exports.Environment = Environment = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A local download failure after a project has completed remotely.
|
|
3
|
+
*/
|
|
4
|
+
export declare class DownloadError extends Error {
|
|
5
|
+
readonly downloadedPaths: string[];
|
|
6
|
+
readonly downloadErrors: {
|
|
7
|
+
stage: "directory" | "file";
|
|
8
|
+
message: string;
|
|
9
|
+
url?: string;
|
|
10
|
+
}[];
|
|
11
|
+
constructor(downloadedPaths: string[], downloadErrors: {
|
|
12
|
+
stage: "directory" | "file";
|
|
13
|
+
message: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}[]);
|
|
16
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DownloadError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A local download failure after a project has completed remotely.
|
|
6
|
+
*/
|
|
7
|
+
class DownloadError extends Error {
|
|
8
|
+
constructor(downloadedPaths, downloadErrors) {
|
|
9
|
+
super("Generated outputs could not all be downloaded. Retry the download URLs without generating again.");
|
|
10
|
+
this.downloadedPaths = downloadedPaths;
|
|
11
|
+
this.downloadErrors = downloadErrors;
|
|
12
|
+
this.name = "DownloadError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.DownloadError = DownloadError;
|
package/dist/helpers/download.js
CHANGED
|
@@ -50,17 +50,29 @@ const fs = __importStar(require("fs"));
|
|
|
50
50
|
const path = __importStar(require("path"));
|
|
51
51
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
52
52
|
const logger_1 = require("../logger.js");
|
|
53
|
+
const download_error_1 = require("./download-error.js");
|
|
53
54
|
/**
|
|
54
55
|
* Download files from the given download URLs
|
|
55
56
|
*/
|
|
56
57
|
function downloadFiles(downloads, downloadDirectory) {
|
|
57
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
59
|
const downloadedPaths = [];
|
|
60
|
+
const downloadErrors = [];
|
|
59
61
|
// Use current working directory if no download directory specified
|
|
60
62
|
const baseDir = downloadDirectory || process.cwd();
|
|
61
63
|
// Ensure the download directory exists
|
|
62
|
-
|
|
63
|
-
fs.
|
|
64
|
+
try {
|
|
65
|
+
if (!fs.existsSync(baseDir)) {
|
|
66
|
+
fs.mkdirSync(baseDir, { recursive: true });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
throw new download_error_1.DownloadError([], [
|
|
71
|
+
{
|
|
72
|
+
stage: "directory",
|
|
73
|
+
message: error instanceof Error ? error.message : String(error),
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
64
76
|
}
|
|
65
77
|
(0, logger_1.getLogger)().debug(`Downloading outputs to ${baseDir}`);
|
|
66
78
|
for (const download of downloads) {
|
|
@@ -80,9 +92,17 @@ function downloadFiles(downloads, downloadDirectory) {
|
|
|
80
92
|
downloadedPaths.push(filePath);
|
|
81
93
|
}
|
|
82
94
|
catch (error) {
|
|
95
|
+
downloadErrors.push({
|
|
96
|
+
stage: "file",
|
|
97
|
+
url: download.url,
|
|
98
|
+
message: error instanceof Error ? error.message : String(error),
|
|
99
|
+
});
|
|
83
100
|
(0, logger_1.getLogger)().error(`Error downloading file from ${download.url}: ${error}`);
|
|
84
101
|
}
|
|
85
102
|
}
|
|
103
|
+
if (downloadErrors.length > 0) {
|
|
104
|
+
throw new download_error_1.DownloadError(downloadedPaths, downloadErrors);
|
|
105
|
+
}
|
|
86
106
|
return downloadedPaths;
|
|
87
107
|
});
|
|
88
108
|
}
|
|
@@ -14,13 +14,21 @@ export type CreateRequest = {
|
|
|
14
14
|
*/
|
|
15
15
|
endSeconds: number;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* Deprecated: use `resolution`. Still accepted as a larger-dimension cap, limited by your plan. Ignored when `resolution` is provided.
|
|
18
|
+
*
|
|
19
|
+
* After plan capping:
|
|
20
|
+
* * Below 1280 maps to `480p` (intermediate values round down).
|
|
21
|
+
* * 1280 or above maps to `720p`.
|
|
18
22
|
*/
|
|
19
23
|
maxResolution?: number | undefined;
|
|
20
24
|
/**
|
|
21
25
|
* Give your video a custom name for easy identification.
|
|
22
26
|
*/
|
|
23
27
|
name?: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Output preset. Overrides `max_resolution`. Defaults to 480p in prompted mode; realistic mode uses the mapped plan maximum.
|
|
30
|
+
*/
|
|
31
|
+
resolution?: ("480p" | "720p") | undefined;
|
|
24
32
|
/**
|
|
25
33
|
* The start time of the input audio in seconds. Maximum clip length depends on style.generation_mode: realistic 300s, prompted 45s.
|
|
26
34
|
*/
|
|
@@ -40,6 +48,7 @@ export type External$CreateRequest = {
|
|
|
40
48
|
end_seconds: number;
|
|
41
49
|
max_resolution?: number | undefined;
|
|
42
50
|
name?: string | undefined;
|
|
51
|
+
resolution?: ("480p" | "720p") | undefined;
|
|
43
52
|
start_seconds: number;
|
|
44
53
|
style?: External$V1AiTalkingPhotoCreateBodyStyle | undefined;
|
|
45
54
|
};
|
|
@@ -47,6 +47,7 @@ const SchemaIn$CreateRequest = z
|
|
|
47
47
|
end_seconds: z.number(),
|
|
48
48
|
max_resolution: z.number().int().optional(),
|
|
49
49
|
name: z.string().optional(),
|
|
50
|
+
resolution: z.enum(["480p", "720p"]).optional(),
|
|
50
51
|
start_seconds: z.number(),
|
|
51
52
|
style: v1_ai_talking_photo_create_body_style_1.Schemas$V1AiTalkingPhotoCreateBodyStyle.in.optional(),
|
|
52
53
|
})
|
|
@@ -56,6 +57,7 @@ const SchemaIn$CreateRequest = z
|
|
|
56
57
|
end_seconds: "endSeconds",
|
|
57
58
|
max_resolution: "maxResolution",
|
|
58
59
|
name: "name",
|
|
60
|
+
resolution: "resolution",
|
|
59
61
|
start_seconds: "startSeconds",
|
|
60
62
|
style: "style",
|
|
61
63
|
});
|
|
@@ -70,6 +72,7 @@ const SchemaOut$CreateRequest = z
|
|
|
70
72
|
endSeconds: z.number(),
|
|
71
73
|
maxResolution: z.number().int().optional(),
|
|
72
74
|
name: z.string().optional(),
|
|
75
|
+
resolution: z.enum(["480p", "720p"]).optional(),
|
|
73
76
|
startSeconds: z.number(),
|
|
74
77
|
style: v1_ai_talking_photo_create_body_style_1.Schemas$V1AiTalkingPhotoCreateBodyStyle.out.optional(),
|
|
75
78
|
})
|
|
@@ -79,6 +82,7 @@ const SchemaOut$CreateRequest = z
|
|
|
79
82
|
endSeconds: "end_seconds",
|
|
80
83
|
maxResolution: "max_resolution",
|
|
81
84
|
name: "name",
|
|
85
|
+
resolution: "resolution",
|
|
82
86
|
startSeconds: "start_seconds",
|
|
83
87
|
style: "style",
|
|
84
88
|
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AiUgcAdClient = void 0;
|
|
4
|
+
var resource_client_1 = require("./resource-client");
|
|
5
|
+
Object.defineProperty(exports, "AiUgcAdClient", { enumerable: true, get: function () { return resource_client_1.AiUgcAdClient; } });
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { External$V1AiUgcAdCreateBodyAssets, V1AiUgcAdCreateBodyAssets } from "../../../types/v1-ai-ugc-ad-create-body-assets.js";
|
|
3
|
+
/**
|
|
4
|
+
* CreateRequest
|
|
5
|
+
*/
|
|
6
|
+
export type CreateRequest = {
|
|
7
|
+
assets: V1AiUgcAdCreateBodyAssets;
|
|
8
|
+
/**
|
|
9
|
+
* Video duration in seconds. Supported values by model:
|
|
10
|
+
* * kling-3.0: 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 seconds.
|
|
11
|
+
* * ltx-2.5: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60 seconds.
|
|
12
|
+
* * veo3.1: 4, 6, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92, 99, 106, 113, 120, 127, 134, 141 seconds.
|
|
13
|
+
* Free plans are limited to 5 seconds unless a credit pack has been purchased.
|
|
14
|
+
*/
|
|
15
|
+
endSeconds: number;
|
|
16
|
+
/**
|
|
17
|
+
* Defaults to kling-3.0 on paid plans and ltx-2.5 on free plans.
|
|
18
|
+
*/
|
|
19
|
+
model?: ("kling-3.0" | "ltx-2.5" | "veo3.1") | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Defaults to 720p on paid plans and 480p on free plans. Unsupported model/resolution combinations and resolutions unavailable for your plan are rejected.
|
|
22
|
+
*/
|
|
23
|
+
resolution?: ("1080p" | "480p" | "720p") | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The words the actor should speak. Character limits apply after trimming:
|
|
26
|
+
* * kling-3.0: 2500 characters.
|
|
27
|
+
* * ltx-2.5: 1804 characters.
|
|
28
|
+
* * veo3.1: 2500 characters.
|
|
29
|
+
* LTX's dialogue wrapper counts toward its model prompt limit.
|
|
30
|
+
*/
|
|
31
|
+
script: string;
|
|
32
|
+
[additionalProperty: string]: V1AiUgcAdCreateBodyAssets | number | (("kling-3.0" | "ltx-2.5" | "veo3.1") | undefined) | (("1080p" | "480p" | "720p") | undefined) | string | any | null | undefined;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* @internal
|
|
36
|
+
* CreateRequest without any key transformation, this is what
|
|
37
|
+
* we expect to come in as network data
|
|
38
|
+
*/
|
|
39
|
+
export type External$CreateRequest = {
|
|
40
|
+
assets: External$V1AiUgcAdCreateBodyAssets;
|
|
41
|
+
end_seconds: number;
|
|
42
|
+
model?: ("kling-3.0" | "ltx-2.5" | "veo3.1") | undefined;
|
|
43
|
+
resolution?: ("1080p" | "480p" | "720p") | undefined;
|
|
44
|
+
script: string;
|
|
45
|
+
[additionalProperty: string]: External$V1AiUgcAdCreateBodyAssets | number | (("kling-3.0" | "ltx-2.5" | "veo3.1") | undefined) | (("1080p" | "480p" | "720p") | undefined) | string | External$CreateRequest | null | undefined;
|
|
46
|
+
};
|
|
47
|
+
export declare const Schemas$CreateRequest: {
|
|
48
|
+
in: z.ZodType<CreateRequest, z.ZodTypeDef, unknown>;
|
|
49
|
+
out: z.ZodType<External$CreateRequest, z.ZodTypeDef, CreateRequest>;
|
|
50
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Schemas$CreateRequest = void 0;
|
|
37
|
+
const make_api_request_js_1 = require("make-api-request-js");
|
|
38
|
+
const z = __importStar(require("zod"));
|
|
39
|
+
const v1_ai_ugc_ad_create_body_assets_1 = require("../../../types/v1-ai-ugc-ad-create-body-assets.js");
|
|
40
|
+
/**
|
|
41
|
+
* Takes network data, validates it, and transforms keys to match typescript object CreateRequest
|
|
42
|
+
*/
|
|
43
|
+
const SchemaIn$CreateRequest = z
|
|
44
|
+
.object({
|
|
45
|
+
assets: v1_ai_ugc_ad_create_body_assets_1.Schemas$V1AiUgcAdCreateBodyAssets.in,
|
|
46
|
+
end_seconds: z.number(),
|
|
47
|
+
model: z.enum(["kling-3.0", "ltx-2.5", "veo3.1"]).optional(),
|
|
48
|
+
resolution: z.enum(["1080p", "480p", "720p"]).optional(),
|
|
49
|
+
script: z.string(),
|
|
50
|
+
})
|
|
51
|
+
.catchall(make_api_request_js_1.zodRequiredAny)
|
|
52
|
+
.transform((obj) => {
|
|
53
|
+
return (0, make_api_request_js_1.zodTransform)(obj, {
|
|
54
|
+
assets: "assets",
|
|
55
|
+
end_seconds: "endSeconds",
|
|
56
|
+
model: "model",
|
|
57
|
+
resolution: "resolution",
|
|
58
|
+
script: "script",
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* @internal
|
|
63
|
+
* Takes typescript data, validates it, and maps keys to match the expected external object External$CreateRequest
|
|
64
|
+
*/
|
|
65
|
+
const SchemaOut$CreateRequest = z
|
|
66
|
+
.object({
|
|
67
|
+
assets: v1_ai_ugc_ad_create_body_assets_1.Schemas$V1AiUgcAdCreateBodyAssets.out,
|
|
68
|
+
endSeconds: z.number(),
|
|
69
|
+
model: z.enum(["kling-3.0", "ltx-2.5", "veo3.1"]).optional(),
|
|
70
|
+
resolution: z.enum(["1080p", "480p", "720p"]).optional(),
|
|
71
|
+
script: z.string(),
|
|
72
|
+
})
|
|
73
|
+
.catchall(make_api_request_js_1.zodRequiredAny)
|
|
74
|
+
.transform((obj) => {
|
|
75
|
+
return (0, make_api_request_js_1.zodTransform)(obj, {
|
|
76
|
+
assets: "assets",
|
|
77
|
+
endSeconds: "end_seconds",
|
|
78
|
+
model: "model",
|
|
79
|
+
resolution: "resolution",
|
|
80
|
+
script: "script",
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
exports.Schemas$CreateRequest = {
|
|
84
|
+
in: SchemaIn$CreateRequest,
|
|
85
|
+
out: SchemaOut$CreateRequest,
|
|
86
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "make-api-request-js";
|
|
2
|
+
import { GenerateOptions } from "../../../helpers/generate-type.js";
|
|
3
|
+
import * as requests from "./request-types.js";
|
|
4
|
+
import * as types from "../../../types/index.js";
|
|
5
|
+
type GenerateRequest = requests.CreateRequest & {
|
|
6
|
+
assets: {
|
|
7
|
+
/**
|
|
8
|
+
* Prepared image to animate. Accepts a local image path or a direct URL.
|
|
9
|
+
* Paths beginning with `api-assets` are already uploaded and reused as is.
|
|
10
|
+
*/
|
|
11
|
+
imageFilePath: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare class AiUgcAdClient extends CoreResourceClient {
|
|
15
|
+
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Generate a UGC ad with automatic image upload, polling, and downloads.
|
|
18
|
+
*
|
|
19
|
+
* Accepts the same request fields as create(), including model and resolution.
|
|
20
|
+
* The prepared image may be a local path, URL, or existing api-assets path.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const result = await client.v1.aiUgcAd.generate({
|
|
25
|
+
* assets: { imageFilePath: "path/to/image.jpg" },
|
|
26
|
+
* endSeconds: 4,
|
|
27
|
+
* script: "Meet your new everyday essential.",
|
|
28
|
+
* });
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../video-projects/resource-client").V1VideoProjectsGetResponseWithDownloads>;
|
|
32
|
+
/**
|
|
33
|
+
* AI UGC Ad Generator
|
|
34
|
+
*
|
|
35
|
+
* Create a spoken UGC video from a prepared image and script. Returns a project ID; poll GET /v1/video-projects/{id} for status and downloads. To compose an image, generate the image separately with the Image Editor API and supply its download URL.
|
|
36
|
+
*
|
|
37
|
+
* POST /v1/ai-ugc-ad
|
|
38
|
+
*/
|
|
39
|
+
create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiUgcAdCreateResponse>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
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 __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.AiUgcAdClient = void 0;
|
|
24
|
+
const make_api_request_js_1 = require("make-api-request-js");
|
|
25
|
+
const logger_1 = require("../../../logger.js");
|
|
26
|
+
const files_1 = require("../files/index.js");
|
|
27
|
+
const video_projects_1 = require("../video-projects/index.js");
|
|
28
|
+
const v1_ai_ugc_ad_create_body_1 = require("../../../types/v1-ai-ugc-ad-create-body.js");
|
|
29
|
+
const v1_ai_ugc_ad_create_response_1 = require("../../../types/v1-ai-ugc-ad-create-response.js");
|
|
30
|
+
class AiUgcAdClient extends make_api_request_js_1.CoreResourceClient {
|
|
31
|
+
constructor(coreClient, opts) {
|
|
32
|
+
super(coreClient, opts);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Generate a UGC ad with automatic image upload, polling, and downloads.
|
|
36
|
+
*
|
|
37
|
+
* Accepts the same request fields as create(), including model and resolution.
|
|
38
|
+
* The prepared image may be a local path, URL, or existing api-assets path.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const result = await client.v1.aiUgcAd.generate({
|
|
43
|
+
* assets: { imageFilePath: "path/to/image.jpg" },
|
|
44
|
+
* endSeconds: 4,
|
|
45
|
+
* script: "Meet your new everyday essential.",
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
generate(request_1) {
|
|
50
|
+
return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
|
|
51
|
+
const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
|
|
52
|
+
const fileClient = new files_1.FilesClient(this._client, this._opts);
|
|
53
|
+
const uploadedImageFilePath = yield fileClient.uploadFile(request.assets.imageFilePath);
|
|
54
|
+
const createResponse = yield this.create(Object.assign(Object.assign({}, request), { assets: Object.assign(Object.assign({}, request.assets), { imageFilePath: uploadedImageFilePath }) }), createOpts);
|
|
55
|
+
(0, logger_1.getLogger)().info(`Created AiUgcAdClient project ${createResponse.id}`);
|
|
56
|
+
const projectsClient = new video_projects_1.VideoProjectsClient(this._client, this._opts);
|
|
57
|
+
return projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
|
|
58
|
+
downloadOutputs,
|
|
59
|
+
downloadDirectory }, createOpts));
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* AI UGC Ad Generator
|
|
64
|
+
*
|
|
65
|
+
* Create a spoken UGC video from a prepared image and script. Returns a project ID; poll GET /v1/video-projects/{id} for status and downloads. To compose an image, generate the image separately with the Image Editor API and supply its download URL.
|
|
66
|
+
*
|
|
67
|
+
* POST /v1/ai-ugc-ad
|
|
68
|
+
*/
|
|
69
|
+
create(request, opts) {
|
|
70
|
+
return this._client.makeRequest({
|
|
71
|
+
method: "post",
|
|
72
|
+
path: "/v1/ai-ugc-ad",
|
|
73
|
+
auth: ["bearerAuth"],
|
|
74
|
+
contentType: "application/json",
|
|
75
|
+
body: v1_ai_ugc_ad_create_body_1.Schemas$V1AiUgcAdCreateBody.out.parse(request),
|
|
76
|
+
responseSchema: v1_ai_ugc_ad_create_response_1.Schemas$V1AiUgcAdCreateResponse.in,
|
|
77
|
+
opts,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.AiUgcAdClient = AiUgcAdClient;
|
|
@@ -61,7 +61,7 @@ export declare class AiVideoEditorClient extends CoreResourceClient {
|
|
|
61
61
|
*
|
|
62
62
|
* **Key options**
|
|
63
63
|
* - Inputs: usually a file, sometimes a YouTube link, depending on project type
|
|
64
|
-
* - Resolution:
|
|
64
|
+
* - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
|
|
65
65
|
* - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
|
|
66
66
|
*
|
|
67
67
|
* **Cost**
|
|
@@ -95,7 +95,7 @@ class AiVideoEditorClient extends make_api_request_js_1.CoreResourceClient {
|
|
|
95
95
|
*
|
|
96
96
|
* **Key options**
|
|
97
97
|
* - Inputs: usually a file, sometimes a YouTube link, depending on project type
|
|
98
|
-
* - Resolution:
|
|
98
|
+
* - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
|
|
99
99
|
* - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
|
|
100
100
|
*
|
|
101
101
|
* **Cost**
|
|
@@ -28,7 +28,7 @@ export declare class AiVideoTranslatorClient extends CoreResourceClient {
|
|
|
28
28
|
*
|
|
29
29
|
* **Key options**
|
|
30
30
|
* - Inputs: usually a file, sometimes a YouTube link, depending on project type
|
|
31
|
-
* - Resolution:
|
|
31
|
+
* - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
|
|
32
32
|
* - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
|
|
33
33
|
*
|
|
34
34
|
* **Cost**
|
|
@@ -59,7 +59,7 @@ class AiVideoTranslatorClient extends make_api_request_js_1.CoreResourceClient {
|
|
|
59
59
|
*
|
|
60
60
|
* **Key options**
|
|
61
61
|
* - Inputs: usually a file, sometimes a YouTube link, depending on project type
|
|
62
|
-
* - Resolution:
|
|
62
|
+
* - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
|
|
63
63
|
* - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
|
|
64
64
|
*
|
|
65
65
|
* **Cost**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "make-api-request-js";
|
|
2
2
|
import { types } from "../../../index.js";
|
|
3
|
+
import { DownloadError } from "../../../helpers/download-error.js";
|
|
3
4
|
import { GenerateOptions } from "../../../helpers/generate-type.js";
|
|
4
5
|
import * as requests from "./request-types.js";
|
|
5
6
|
/**
|
|
@@ -11,6 +12,10 @@ export interface V1AudioProjectsGetResponseWithDownloads extends types.V1AudioPr
|
|
|
11
12
|
* This field is only populated if `download_outputs` is True and the audio project is complete.
|
|
12
13
|
*/
|
|
13
14
|
downloadedPaths?: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Local download failures. The completed project and remote download URLs remain available.
|
|
17
|
+
*/
|
|
18
|
+
downloadErrors?: DownloadError["downloadErrors"];
|
|
14
19
|
}
|
|
15
20
|
export declare class AudioProjectsClient extends CoreResourceClient {
|
|
16
21
|
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.AudioProjectsClient = void 0;
|
|
24
24
|
const make_api_request_js_1 = require("make-api-request-js");
|
|
25
25
|
const download_1 = require("../../../helpers/download.js");
|
|
26
|
+
const download_error_1 = require("../../../helpers/download-error.js");
|
|
26
27
|
const sleep_1 = require("../../../helpers/sleep.js");
|
|
27
28
|
const logger_1 = require("../../../logger.js");
|
|
28
29
|
const v1_audio_projects_get_response_1 = require("../../../types/v1-audio-projects-get-response.js");
|
|
@@ -70,9 +71,20 @@ class AudioProjectsClient extends make_api_request_js_1.CoreResourceClient {
|
|
|
70
71
|
return Object.assign({}, apiResponse);
|
|
71
72
|
}
|
|
72
73
|
(0, logger_1.getLogger)().debug(`Downloading outputs for audio project ${request.id} to ${downloadDirectory !== null && downloadDirectory !== void 0 ? downloadDirectory : "current directory"}`);
|
|
73
|
-
|
|
74
|
+
let downloadedPaths;
|
|
75
|
+
let downloadErrors = [];
|
|
76
|
+
try {
|
|
77
|
+
downloadedPaths = yield (0, download_1.downloadFiles)(apiResponse.downloads, downloadDirectory);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
if (!(error instanceof download_error_1.DownloadError)) {
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
downloadedPaths = error.downloadedPaths;
|
|
84
|
+
downloadErrors = error.downloadErrors;
|
|
85
|
+
}
|
|
74
86
|
(0, logger_1.getLogger)().info(`Downloaded outputs for audio project ${request.id} to ${downloadedPaths}`);
|
|
75
|
-
return Object.assign(Object.assign({}, apiResponse), { downloadedPaths });
|
|
87
|
+
return Object.assign(Object.assign(Object.assign({}, apiResponse), { downloadedPaths }), (downloadErrors.length > 0 ? { downloadErrors } : {}));
|
|
76
88
|
});
|
|
77
89
|
}
|
|
78
90
|
/**
|
|
@@ -72,7 +72,7 @@ export declare class AudioToVideoClient extends CoreResourceClient {
|
|
|
72
72
|
*
|
|
73
73
|
* **Key options**
|
|
74
74
|
* - Inputs: usually a file, sometimes a YouTube link, depending on project type
|
|
75
|
-
* - Resolution:
|
|
75
|
+
* - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
|
|
76
76
|
* - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
|
|
77
77
|
*
|
|
78
78
|
* **Cost**
|
|
@@ -109,7 +109,7 @@ class AudioToVideoClient extends make_api_request_js_1.CoreResourceClient {
|
|
|
109
109
|
*
|
|
110
110
|
* **Key options**
|
|
111
111
|
* - Inputs: usually a file, sometimes a YouTube link, depending on project type
|
|
112
|
-
* - Resolution:
|
|
112
|
+
* - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
|
|
113
113
|
* - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
|
|
114
114
|
*
|
|
115
115
|
* **Cost**
|
|
@@ -73,7 +73,7 @@ export declare class CharacterReplaceClient extends CoreResourceClient {
|
|
|
73
73
|
*
|
|
74
74
|
* **Key options**
|
|
75
75
|
* - Inputs: usually a file, sometimes a YouTube link, depending on project type
|
|
76
|
-
* - Resolution:
|
|
76
|
+
* - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
|
|
77
77
|
* - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
|
|
78
78
|
*
|
|
79
79
|
* **Cost**
|
|
@@ -104,7 +104,7 @@ class CharacterReplaceClient extends make_api_request_js_1.CoreResourceClient {
|
|
|
104
104
|
*
|
|
105
105
|
* **Key options**
|
|
106
106
|
* - Inputs: usually a file, sometimes a YouTube link, depending on project type
|
|
107
|
-
* - Resolution:
|
|
107
|
+
* - Resolution: output size and plan requirements vary by workflow and model. Some workflows derive output size from the input video.
|
|
108
108
|
* - Extra fields: e.g. `face_swap_mode`, `start_seconds`/`end_seconds`, or a text prompt
|
|
109
109
|
*
|
|
110
110
|
* **Cost**
|
|
@@ -26,6 +26,11 @@ export declare class FaceDetectionClient extends CoreResourceClient {
|
|
|
26
26
|
id: string;
|
|
27
27
|
status: "complete" | "error" | "queued" | "rendering";
|
|
28
28
|
} | {
|
|
29
|
+
downloadErrors?: {
|
|
30
|
+
stage: "directory" | "file";
|
|
31
|
+
message: string;
|
|
32
|
+
url?: string;
|
|
33
|
+
}[];
|
|
29
34
|
downloadedPaths: string[];
|
|
30
35
|
creditsCharged: number;
|
|
31
36
|
faces: types.V1FaceDetectionGetResponseFacesItem[];
|