magic-hour 0.36.0 → 0.37.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 +202 -10
- package/dist/helpers/download.d.ts +5 -0
- package/dist/helpers/download.js +88 -0
- package/dist/helpers/generate-type.d.ts +51 -0
- package/dist/helpers/generate-type.js +2 -0
- package/dist/helpers/sleep.d.ts +4 -0
- package/dist/helpers/sleep.js +9 -0
- package/dist/logger.d.ts +48 -0
- package/dist/logger.js +97 -0
- package/dist/resources/v1/ai-clothes-changer/resource-client.d.ts +50 -0
- package/dist/resources/v1/ai-clothes-changer/resource-client.js +75 -0
- package/dist/resources/v1/ai-face-editor/resource-client.d.ts +55 -0
- package/dist/resources/v1/ai-face-editor/resource-client.js +85 -0
- package/dist/resources/v1/ai-gif-generator/resource-client.d.ts +29 -0
- package/dist/resources/v1/ai-gif-generator/resource-client.js +60 -0
- package/dist/resources/v1/ai-headshot-generator/resource-client.d.ts +38 -0
- package/dist/resources/v1/ai-headshot-generator/resource-client.js +68 -0
- package/dist/resources/v1/ai-image-editor/resource-client.d.ts +39 -0
- package/dist/resources/v1/ai-image-editor/resource-client.js +69 -0
- package/dist/resources/v1/ai-image-generator/resource-client.d.ts +31 -0
- package/dist/resources/v1/ai-image-generator/resource-client.js +62 -0
- package/dist/resources/v1/ai-image-upscaler/resource-client.d.ts +40 -0
- package/dist/resources/v1/ai-image-upscaler/resource-client.js +70 -0
- package/dist/resources/v1/ai-meme-generator/resource-client.d.ts +33 -0
- package/dist/resources/v1/ai-meme-generator/resource-client.js +64 -0
- package/dist/resources/v1/ai-photo-editor/resource-client.d.ts +49 -0
- package/dist/resources/v1/ai-photo-editor/resource-client.js +79 -0
- package/dist/resources/v1/ai-qr-code-generator/resource-client.d.ts +30 -0
- package/dist/resources/v1/ai-qr-code-generator/resource-client.js +61 -0
- package/dist/resources/v1/ai-talking-photo/resource-client.d.ts +51 -0
- package/dist/resources/v1/ai-talking-photo/resource-client.js +76 -0
- package/dist/resources/v1/animation/resource-client.d.ts +61 -0
- package/dist/resources/v1/animation/resource-client.js +98 -0
- package/dist/resources/v1/auto-subtitle-generator/resource-client.d.ts +41 -0
- package/dist/resources/v1/auto-subtitle-generator/resource-client.js +71 -0
- package/dist/resources/v1/face-detection/resource-client.d.ts +30 -0
- package/dist/resources/v1/face-detection/resource-client.js +75 -0
- package/dist/resources/v1/face-swap/resource-client.d.ts +77 -0
- package/dist/resources/v1/face-swap/resource-client.js +125 -0
- package/dist/resources/v1/face-swap-photo/resource-client.d.ts +73 -0
- package/dist/resources/v1/face-swap-photo/resource-client.js +117 -0
- package/dist/resources/v1/files/resource-client.d.ts +40 -0
- package/dist/resources/v1/files/resource-client.js +236 -0
- package/dist/resources/v1/files/resource-client.test.d.ts +1 -0
- package/dist/resources/v1/files/resource-client.test.js +422 -0
- package/dist/resources/v1/image-background-remover/resource-client.d.ts +49 -0
- package/dist/resources/v1/image-background-remover/resource-client.js +82 -0
- package/dist/resources/v1/image-projects/resource-client.d.ts +22 -0
- package/dist/resources/v1/image-projects/resource-client.js +68 -0
- package/dist/resources/v1/image-projects/resource-client.test.d.ts +1 -0
- package/dist/resources/v1/image-projects/resource-client.test.js +538 -0
- package/dist/resources/v1/image-to-video/resource-client.d.ts +40 -0
- package/dist/resources/v1/image-to-video/resource-client.js +70 -0
- package/dist/resources/v1/lip-sync/resource-client.d.ts +53 -0
- package/dist/resources/v1/lip-sync/resource-client.js +84 -0
- package/dist/resources/v1/photo-colorizer/resource-client.d.ts +38 -0
- package/dist/resources/v1/photo-colorizer/resource-client.js +68 -0
- package/dist/resources/v1/text-to-video/resource-client.d.ts +32 -0
- package/dist/resources/v1/text-to-video/resource-client.js +63 -0
- package/dist/resources/v1/video-projects/resource-client.d.ts +22 -0
- package/dist/resources/v1/video-projects/resource-client.js +68 -0
- package/dist/resources/v1/video-projects/resource-client.test.d.ts +1 -0
- package/dist/resources/v1/video-projects/resource-client.test.js +713 -0
- package/dist/resources/v1/video-to-video/resource-client.d.ts +48 -0
- package/dist/resources/v1/video-to-video/resource-client.js +84 -0
- package/package.json +15 -11
|
@@ -1,13 +1,82 @@
|
|
|
1
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
|
+
};
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.AiImageEditorClient = void 0;
|
|
4
24
|
const core_1 = require("../../../core");
|
|
25
|
+
const files_1 = require("../../../resources/v1/files");
|
|
5
26
|
const v1_ai_image_editor_create_body_1 = require("../../../types/v1-ai-image-editor-create-body");
|
|
6
27
|
const v1_ai_image_editor_create_response_1 = require("../../../types/v1-ai-image-editor-create-response");
|
|
28
|
+
const logger_1 = require("../../../logger");
|
|
29
|
+
const image_projects_1 = require("../../../resources/v1/image-projects");
|
|
7
30
|
class AiImageEditorClient extends core_1.CoreResourceClient {
|
|
8
31
|
constructor(coreClient, opts) {
|
|
9
32
|
super(coreClient, opts);
|
|
10
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* AI Image Editor
|
|
36
|
+
*
|
|
37
|
+
* Edit images with AI
|
|
38
|
+
*
|
|
39
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import Client from "../../../index.js";
|
|
44
|
+
*
|
|
45
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
46
|
+
* const res = await client.v1.aiImageEditor.generate(
|
|
47
|
+
* {
|
|
48
|
+
* assets: { imageFilePath: "/path/to/1234.png" },
|
|
49
|
+
* name: "Ai Image Editor image",
|
|
50
|
+
* style: { prompt: "Give me sunglasses" },
|
|
51
|
+
* },
|
|
52
|
+
* {
|
|
53
|
+
* waitForCompletion: true,
|
|
54
|
+
* downloadOutputs: true,
|
|
55
|
+
* downloadDirectory: "outputs",
|
|
56
|
+
* },
|
|
57
|
+
* );
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
generate(request_1) {
|
|
61
|
+
return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
|
|
62
|
+
const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
|
|
63
|
+
const fileClient = new files_1.FilesClient(this._client, this._opts);
|
|
64
|
+
const _a = request.assets, { imageFilePath } = _a, restAssets = __rest(_a, ["imageFilePath"]);
|
|
65
|
+
(0, logger_1.getLogger)().debug(`Uploading file ${imageFilePath} to Magic Hour's storage`);
|
|
66
|
+
const [uploadedImageFilePath] = yield Promise.all([
|
|
67
|
+
fileClient.uploadFile(imageFilePath),
|
|
68
|
+
]);
|
|
69
|
+
(0, logger_1.getLogger)().info(`Uploaded file ${imageFilePath} to Magic Hour's storage as ${uploadedImageFilePath}`);
|
|
70
|
+
const createResponse = yield this.create(Object.assign(Object.assign({}, request), { assets: Object.assign(Object.assign({}, restAssets), { imageFilePath: uploadedImageFilePath }) }), createOpts);
|
|
71
|
+
(0, logger_1.getLogger)().info(`Created AiImageEditorClient project ${createResponse.id}`);
|
|
72
|
+
const projectsClient = new image_projects_1.ImageProjectsClient(this._client, this._opts);
|
|
73
|
+
(0, logger_1.getLogger)().debug(`Checking result for AiImageEditorClient project ${createResponse.id}`);
|
|
74
|
+
const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
|
|
75
|
+
downloadOutputs,
|
|
76
|
+
downloadDirectory }, createOpts));
|
|
77
|
+
return result;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
11
80
|
/**
|
|
12
81
|
* AI Image Editor
|
|
13
82
|
*
|
|
@@ -1,8 +1,38 @@
|
|
|
1
1
|
import { types } from "../../../index.js";
|
|
2
2
|
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "../../../core";
|
|
3
|
+
import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type";
|
|
3
4
|
import * as requests from "../../../resources/v1/ai-image-generator/request-types";
|
|
5
|
+
type GenerateRequest = GenerateRequestType<requests.CreateRequest, {}>;
|
|
4
6
|
export declare class AiImageGeneratorClient extends CoreResourceClient {
|
|
5
7
|
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
8
|
+
/**
|
|
9
|
+
* AI Images
|
|
10
|
+
*
|
|
11
|
+
* Create an AI image
|
|
12
|
+
*
|
|
13
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import Client from "../../../index.js";
|
|
18
|
+
*
|
|
19
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
20
|
+
* const res = await client.v1.aiImageGenerator.generate(
|
|
21
|
+
* {
|
|
22
|
+
* imageCount: 1,
|
|
23
|
+
* name: "Ai Image image",
|
|
24
|
+
* orientation: "landscape",
|
|
25
|
+
* style: { prompt: "Cool image", tool: "ai-anime-generator" },
|
|
26
|
+
* },
|
|
27
|
+
* {
|
|
28
|
+
* waitForCompletion: true,
|
|
29
|
+
* downloadOutputs: true,
|
|
30
|
+
* downloadDirectory: "outputs",
|
|
31
|
+
* },
|
|
32
|
+
* );
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../image-projects/resource-client").V1ImageProjectsGetResponseWithDownloads>;
|
|
6
36
|
/**
|
|
7
37
|
* AI Images
|
|
8
38
|
*
|
|
@@ -12,3 +42,4 @@ export declare class AiImageGeneratorClient extends CoreResourceClient {
|
|
|
12
42
|
*/
|
|
13
43
|
create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiImageGeneratorCreateResponse>;
|
|
14
44
|
}
|
|
45
|
+
export {};
|
|
@@ -1,13 +1,75 @@
|
|
|
1
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
|
+
};
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.AiImageGeneratorClient = void 0;
|
|
4
24
|
const core_1 = require("../../../core");
|
|
5
25
|
const v1_ai_image_generator_create_body_1 = require("../../../types/v1-ai-image-generator-create-body");
|
|
6
26
|
const v1_ai_image_generator_create_response_1 = require("../../../types/v1-ai-image-generator-create-response");
|
|
27
|
+
const logger_1 = require("../../../logger");
|
|
28
|
+
const image_projects_1 = require("../../../resources/v1/image-projects");
|
|
7
29
|
class AiImageGeneratorClient extends core_1.CoreResourceClient {
|
|
8
30
|
constructor(coreClient, opts) {
|
|
9
31
|
super(coreClient, opts);
|
|
10
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* AI Images
|
|
35
|
+
*
|
|
36
|
+
* Create an AI image
|
|
37
|
+
*
|
|
38
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import Client from "../../../index.js";
|
|
43
|
+
*
|
|
44
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
45
|
+
* const res = await client.v1.aiImageGenerator.generate(
|
|
46
|
+
* {
|
|
47
|
+
* imageCount: 1,
|
|
48
|
+
* name: "Ai Image image",
|
|
49
|
+
* orientation: "landscape",
|
|
50
|
+
* style: { prompt: "Cool image", tool: "ai-anime-generator" },
|
|
51
|
+
* },
|
|
52
|
+
* {
|
|
53
|
+
* waitForCompletion: true,
|
|
54
|
+
* downloadOutputs: true,
|
|
55
|
+
* downloadDirectory: "outputs",
|
|
56
|
+
* },
|
|
57
|
+
* );
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
generate(request_1) {
|
|
61
|
+
return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
|
|
62
|
+
const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
|
|
63
|
+
const createResponse = yield this.create(request, createOpts);
|
|
64
|
+
(0, logger_1.getLogger)().info(`Created AiImageGeneratorClient project ${createResponse.id}`);
|
|
65
|
+
const projectsClient = new image_projects_1.ImageProjectsClient(this._client, this._opts);
|
|
66
|
+
(0, logger_1.getLogger)().debug(`Checking result for AiImageGeneratorClient project ${createResponse.id}`);
|
|
67
|
+
const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
|
|
68
|
+
downloadOutputs,
|
|
69
|
+
downloadDirectory }, createOpts));
|
|
70
|
+
return result;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
11
73
|
/**
|
|
12
74
|
* AI Images
|
|
13
75
|
*
|
|
@@ -1,8 +1,47 @@
|
|
|
1
1
|
import { types } from "../../../index.js";
|
|
2
2
|
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "../../../core";
|
|
3
|
+
import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type";
|
|
3
4
|
import * as requests from "../../../resources/v1/ai-image-upscaler/request-types";
|
|
5
|
+
type GenerateRequest = GenerateRequestType<requests.CreateRequest, {
|
|
6
|
+
/**
|
|
7
|
+
* The image to upscale. This value is either
|
|
8
|
+
* - a direct URL to the image file
|
|
9
|
+
* - a path to a local file
|
|
10
|
+
*
|
|
11
|
+
* Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
|
|
12
|
+
*/
|
|
13
|
+
imageFilePath: string;
|
|
14
|
+
}>;
|
|
4
15
|
export declare class AiImageUpscalerClient extends CoreResourceClient {
|
|
5
16
|
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
17
|
+
/**
|
|
18
|
+
* AI Image Upscaler
|
|
19
|
+
*
|
|
20
|
+
* Upscale your image using AI
|
|
21
|
+
*
|
|
22
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import Client from "../../../index.js";
|
|
27
|
+
*
|
|
28
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
29
|
+
* const res = await client.v1.aiImageUpscaler.generate(
|
|
30
|
+
* {
|
|
31
|
+
* assets: { imageFilePath: "/path/to/1234.png" },
|
|
32
|
+
* name: "Image Upscaler image",
|
|
33
|
+
* scaleFactor: 2.0,
|
|
34
|
+
* style: { enhancement: "Balanced" },
|
|
35
|
+
* },
|
|
36
|
+
* {
|
|
37
|
+
* waitForCompletion: true,
|
|
38
|
+
* downloadOutputs: true,
|
|
39
|
+
* downloadDirectory: "outputs",
|
|
40
|
+
* },
|
|
41
|
+
* );
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../image-projects/resource-client").V1ImageProjectsGetResponseWithDownloads>;
|
|
6
45
|
/**
|
|
7
46
|
* AI Image Upscaler
|
|
8
47
|
*
|
|
@@ -12,3 +51,4 @@ export declare class AiImageUpscalerClient extends CoreResourceClient {
|
|
|
12
51
|
*/
|
|
13
52
|
create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiImageUpscalerCreateResponse>;
|
|
14
53
|
}
|
|
54
|
+
export {};
|
|
@@ -1,13 +1,83 @@
|
|
|
1
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
|
+
};
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.AiImageUpscalerClient = void 0;
|
|
4
24
|
const core_1 = require("../../../core");
|
|
25
|
+
const files_1 = require("../../../resources/v1/files");
|
|
5
26
|
const v1_ai_image_upscaler_create_body_1 = require("../../../types/v1-ai-image-upscaler-create-body");
|
|
6
27
|
const v1_ai_image_upscaler_create_response_1 = require("../../../types/v1-ai-image-upscaler-create-response");
|
|
28
|
+
const logger_1 = require("../../../logger");
|
|
29
|
+
const image_projects_1 = require("../../../resources/v1/image-projects");
|
|
7
30
|
class AiImageUpscalerClient extends core_1.CoreResourceClient {
|
|
8
31
|
constructor(coreClient, opts) {
|
|
9
32
|
super(coreClient, opts);
|
|
10
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* AI Image Upscaler
|
|
36
|
+
*
|
|
37
|
+
* Upscale your image using AI
|
|
38
|
+
*
|
|
39
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import Client from "../../../index.js";
|
|
44
|
+
*
|
|
45
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
46
|
+
* const res = await client.v1.aiImageUpscaler.generate(
|
|
47
|
+
* {
|
|
48
|
+
* assets: { imageFilePath: "/path/to/1234.png" },
|
|
49
|
+
* name: "Image Upscaler image",
|
|
50
|
+
* scaleFactor: 2.0,
|
|
51
|
+
* style: { enhancement: "Balanced" },
|
|
52
|
+
* },
|
|
53
|
+
* {
|
|
54
|
+
* waitForCompletion: true,
|
|
55
|
+
* downloadOutputs: true,
|
|
56
|
+
* downloadDirectory: "outputs",
|
|
57
|
+
* },
|
|
58
|
+
* );
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
generate(request_1) {
|
|
62
|
+
return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
|
|
63
|
+
const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
|
|
64
|
+
const fileClient = new files_1.FilesClient(this._client, this._opts);
|
|
65
|
+
const _a = request.assets, { imageFilePath } = _a, restAssets = __rest(_a, ["imageFilePath"]);
|
|
66
|
+
(0, logger_1.getLogger)().debug(`Uploading file ${imageFilePath} to Magic Hour's storage`);
|
|
67
|
+
const [uploadedImageFilePath] = yield Promise.all([
|
|
68
|
+
fileClient.uploadFile(imageFilePath),
|
|
69
|
+
]);
|
|
70
|
+
(0, logger_1.getLogger)().info(`Uploaded file ${imageFilePath} to Magic Hour's storage as ${uploadedImageFilePath}`);
|
|
71
|
+
const createResponse = yield this.create(Object.assign(Object.assign({}, request), { assets: Object.assign(Object.assign({}, restAssets), { imageFilePath: uploadedImageFilePath }) }), createOpts);
|
|
72
|
+
(0, logger_1.getLogger)().info(`Created AiImageUpscalerClient project ${createResponse.id}`);
|
|
73
|
+
const projectsClient = new image_projects_1.ImageProjectsClient(this._client, this._opts);
|
|
74
|
+
(0, logger_1.getLogger)().debug(`Checking result for AiImageUpscalerClient project ${createResponse.id}`);
|
|
75
|
+
const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
|
|
76
|
+
downloadOutputs,
|
|
77
|
+
downloadDirectory }, createOpts));
|
|
78
|
+
return result;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
11
81
|
/**
|
|
12
82
|
* AI Image Upscaler
|
|
13
83
|
*
|
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
import { types } from "../../../index.js";
|
|
2
2
|
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "../../../core";
|
|
3
|
+
import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type";
|
|
3
4
|
import * as requests from "../../../resources/v1/ai-meme-generator/request-types";
|
|
5
|
+
type GenerateRequest = GenerateRequestType<requests.CreateRequest, {}>;
|
|
4
6
|
export declare class AiMemeGeneratorClient extends CoreResourceClient {
|
|
5
7
|
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
8
|
+
/**
|
|
9
|
+
* AI Meme Generator
|
|
10
|
+
*
|
|
11
|
+
* Create an AI generated meme
|
|
12
|
+
*
|
|
13
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import Client from "../../../index.js";
|
|
18
|
+
*
|
|
19
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
20
|
+
* const res = await client.v1.aiMemeGenerator.generate(
|
|
21
|
+
* {
|
|
22
|
+
* name: "My Funny Meme",
|
|
23
|
+
* style: {
|
|
24
|
+
* searchWeb: false,
|
|
25
|
+
* template: "Drake Hotline Bling",
|
|
26
|
+
* topic: "When the code finally works",
|
|
27
|
+
* },
|
|
28
|
+
* },
|
|
29
|
+
* {
|
|
30
|
+
* waitForCompletion: true,
|
|
31
|
+
* downloadOutputs: true,
|
|
32
|
+
* downloadDirectory: "outputs",
|
|
33
|
+
* },
|
|
34
|
+
* );
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../image-projects/resource-client").V1ImageProjectsGetResponseWithDownloads>;
|
|
6
38
|
/**
|
|
7
39
|
* AI Meme Generator
|
|
8
40
|
*
|
|
@@ -12,3 +44,4 @@ export declare class AiMemeGeneratorClient extends CoreResourceClient {
|
|
|
12
44
|
*/
|
|
13
45
|
create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiMemeGeneratorCreateResponse>;
|
|
14
46
|
}
|
|
47
|
+
export {};
|
|
@@ -1,13 +1,77 @@
|
|
|
1
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
|
+
};
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.AiMemeGeneratorClient = void 0;
|
|
4
24
|
const core_1 = require("../../../core");
|
|
5
25
|
const v1_ai_meme_generator_create_body_1 = require("../../../types/v1-ai-meme-generator-create-body");
|
|
6
26
|
const v1_ai_meme_generator_create_response_1 = require("../../../types/v1-ai-meme-generator-create-response");
|
|
27
|
+
const logger_1 = require("../../../logger");
|
|
28
|
+
const image_projects_1 = require("../../../resources/v1/image-projects");
|
|
7
29
|
class AiMemeGeneratorClient extends core_1.CoreResourceClient {
|
|
8
30
|
constructor(coreClient, opts) {
|
|
9
31
|
super(coreClient, opts);
|
|
10
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* AI Meme Generator
|
|
35
|
+
*
|
|
36
|
+
* Create an AI generated meme
|
|
37
|
+
*
|
|
38
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import Client from "../../../index.js";
|
|
43
|
+
*
|
|
44
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
45
|
+
* const res = await client.v1.aiMemeGenerator.generate(
|
|
46
|
+
* {
|
|
47
|
+
* name: "My Funny Meme",
|
|
48
|
+
* style: {
|
|
49
|
+
* searchWeb: false,
|
|
50
|
+
* template: "Drake Hotline Bling",
|
|
51
|
+
* topic: "When the code finally works",
|
|
52
|
+
* },
|
|
53
|
+
* },
|
|
54
|
+
* {
|
|
55
|
+
* waitForCompletion: true,
|
|
56
|
+
* downloadOutputs: true,
|
|
57
|
+
* downloadDirectory: "outputs",
|
|
58
|
+
* },
|
|
59
|
+
* );
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
generate(request_1) {
|
|
63
|
+
return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
|
|
64
|
+
const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
|
|
65
|
+
const createResponse = yield this.create(request, createOpts);
|
|
66
|
+
(0, logger_1.getLogger)().info(`Created AiMemeGeneratorClient project ${createResponse.id}`);
|
|
67
|
+
const projectsClient = new image_projects_1.ImageProjectsClient(this._client, this._opts);
|
|
68
|
+
(0, logger_1.getLogger)().debug(`Checking result for AiMemeGeneratorClient project ${createResponse.id}`);
|
|
69
|
+
const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
|
|
70
|
+
downloadOutputs,
|
|
71
|
+
downloadDirectory }, createOpts));
|
|
72
|
+
return result;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
11
75
|
/**
|
|
12
76
|
* AI Meme Generator
|
|
13
77
|
*
|
|
@@ -1,8 +1,56 @@
|
|
|
1
1
|
import { types } from "../../../index.js";
|
|
2
2
|
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "../../../core";
|
|
3
|
+
import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type";
|
|
3
4
|
import * as requests from "../../../resources/v1/ai-photo-editor/request-types";
|
|
5
|
+
type GenerateRequest = GenerateRequestType<requests.CreateRequest, {
|
|
6
|
+
/**
|
|
7
|
+
* The image used to generate the output. This value is either
|
|
8
|
+
* - a direct URL to the image file
|
|
9
|
+
* - a path to a local file
|
|
10
|
+
*
|
|
11
|
+
* Note: if the path begins with `api-assets`, it will be assumed to already be uploaded to Magic Hour's storage, and will not be uploaded again.
|
|
12
|
+
*/
|
|
13
|
+
imageFilePath: string;
|
|
14
|
+
}>;
|
|
4
15
|
export declare class AiPhotoEditorClient extends CoreResourceClient {
|
|
5
16
|
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
17
|
+
/**
|
|
18
|
+
* AI Photo Editor
|
|
19
|
+
*
|
|
20
|
+
* > **NOTE**: this API is still in early development stages, and should be avoided
|
|
21
|
+
*
|
|
22
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import Client from "../../../index.js";
|
|
27
|
+
*
|
|
28
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
29
|
+
* const res = await client.v1.aiPhotoEditor.generate(
|
|
30
|
+
* {
|
|
31
|
+
* assets: { imageFilePath: "/path/to/1234.png" },
|
|
32
|
+
* name: "Photo Editor image",
|
|
33
|
+
* resolution: 768,
|
|
34
|
+
* style: {
|
|
35
|
+
* imageDescription: "A photo of a person",
|
|
36
|
+
* likenessStrength: 5.2,
|
|
37
|
+
* negativePrompt: "painting, cartoon, sketch",
|
|
38
|
+
* prompt: "A photo portrait of a person wearing a hat",
|
|
39
|
+
* promptStrength: 3.75,
|
|
40
|
+
* steps: 4,
|
|
41
|
+
* upscaleFactor: 2,
|
|
42
|
+
* upscaleFidelity: 0.5,
|
|
43
|
+
* },
|
|
44
|
+
* },
|
|
45
|
+
* {
|
|
46
|
+
* waitForCompletion: true,
|
|
47
|
+
* downloadOutputs: true,
|
|
48
|
+
* downloadDirectory: "outputs",
|
|
49
|
+
* },
|
|
50
|
+
* );
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../image-projects/resource-client").V1ImageProjectsGetResponseWithDownloads>;
|
|
6
54
|
/**
|
|
7
55
|
* AI Photo Editor
|
|
8
56
|
*
|
|
@@ -14,3 +62,4 @@ export declare class AiPhotoEditorClient extends CoreResourceClient {
|
|
|
14
62
|
*/
|
|
15
63
|
create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiPhotoEditorCreateResponse>;
|
|
16
64
|
}
|
|
65
|
+
export {};
|
|
@@ -1,13 +1,92 @@
|
|
|
1
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
|
+
};
|
|
2
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
23
|
exports.AiPhotoEditorClient = void 0;
|
|
4
24
|
const core_1 = require("../../../core");
|
|
25
|
+
const files_1 = require("../../../resources/v1/files");
|
|
5
26
|
const v1_ai_photo_editor_create_body_1 = require("../../../types/v1-ai-photo-editor-create-body");
|
|
6
27
|
const v1_ai_photo_editor_create_response_1 = require("../../../types/v1-ai-photo-editor-create-response");
|
|
28
|
+
const logger_1 = require("../../../logger");
|
|
29
|
+
const image_projects_1 = require("../../../resources/v1/image-projects");
|
|
7
30
|
class AiPhotoEditorClient extends core_1.CoreResourceClient {
|
|
8
31
|
constructor(coreClient, opts) {
|
|
9
32
|
super(coreClient, opts);
|
|
10
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* AI Photo Editor
|
|
36
|
+
*
|
|
37
|
+
* > **NOTE**: this API is still in early development stages, and should be avoided
|
|
38
|
+
*
|
|
39
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* import Client from "../../../index.js";
|
|
44
|
+
*
|
|
45
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
46
|
+
* const res = await client.v1.aiPhotoEditor.generate(
|
|
47
|
+
* {
|
|
48
|
+
* assets: { imageFilePath: "/path/to/1234.png" },
|
|
49
|
+
* name: "Photo Editor image",
|
|
50
|
+
* resolution: 768,
|
|
51
|
+
* style: {
|
|
52
|
+
* imageDescription: "A photo of a person",
|
|
53
|
+
* likenessStrength: 5.2,
|
|
54
|
+
* negativePrompt: "painting, cartoon, sketch",
|
|
55
|
+
* prompt: "A photo portrait of a person wearing a hat",
|
|
56
|
+
* promptStrength: 3.75,
|
|
57
|
+
* steps: 4,
|
|
58
|
+
* upscaleFactor: 2,
|
|
59
|
+
* upscaleFidelity: 0.5,
|
|
60
|
+
* },
|
|
61
|
+
* },
|
|
62
|
+
* {
|
|
63
|
+
* waitForCompletion: true,
|
|
64
|
+
* downloadOutputs: true,
|
|
65
|
+
* downloadDirectory: "outputs",
|
|
66
|
+
* },
|
|
67
|
+
* );
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
generate(request_1) {
|
|
71
|
+
return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
|
|
72
|
+
const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
|
|
73
|
+
const fileClient = new files_1.FilesClient(this._client, this._opts);
|
|
74
|
+
const _a = request.assets, { imageFilePath } = _a, restAssets = __rest(_a, ["imageFilePath"]);
|
|
75
|
+
(0, logger_1.getLogger)().debug(`Uploading file ${imageFilePath} to Magic Hour's storage`);
|
|
76
|
+
const [uploadedImageFilePath] = yield Promise.all([
|
|
77
|
+
fileClient.uploadFile(imageFilePath),
|
|
78
|
+
]);
|
|
79
|
+
(0, logger_1.getLogger)().info(`Uploaded file ${imageFilePath} to Magic Hour's storage as ${uploadedImageFilePath}`);
|
|
80
|
+
const createResponse = yield this.create(Object.assign(Object.assign({}, request), { assets: Object.assign(Object.assign({}, restAssets), { imageFilePath: uploadedImageFilePath }) }), createOpts);
|
|
81
|
+
(0, logger_1.getLogger)().info(`Created AiPhotoEditorClient project ${createResponse.id}`);
|
|
82
|
+
const projectsClient = new image_projects_1.ImageProjectsClient(this._client, this._opts);
|
|
83
|
+
(0, logger_1.getLogger)().debug(`Checking result for AiPhotoEditorClient project ${createResponse.id}`);
|
|
84
|
+
const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
|
|
85
|
+
downloadOutputs,
|
|
86
|
+
downloadDirectory }, createOpts));
|
|
87
|
+
return result;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
11
90
|
/**
|
|
12
91
|
* AI Photo Editor
|
|
13
92
|
*
|
|
@@ -1,8 +1,37 @@
|
|
|
1
1
|
import { types } from "../../../index.js";
|
|
2
2
|
import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "../../../core";
|
|
3
|
+
import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type";
|
|
3
4
|
import * as requests from "../../../resources/v1/ai-qr-code-generator/request-types";
|
|
5
|
+
type GenerateRequest = GenerateRequestType<requests.CreateRequest, {}>;
|
|
4
6
|
export declare class AiQrCodeGeneratorClient extends CoreResourceClient {
|
|
5
7
|
constructor(coreClient: CoreClient, opts: ResourceClientOptions);
|
|
8
|
+
/**
|
|
9
|
+
* AI QR Code
|
|
10
|
+
*
|
|
11
|
+
* Create an AI QR code
|
|
12
|
+
*
|
|
13
|
+
* This method provides a convenient way to create a request and automatically wait for completion and download outputs.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import Client from "../../../index.js";
|
|
18
|
+
*
|
|
19
|
+
* const client = new Client({ token: process.env["API_TOKEN"]!! });
|
|
20
|
+
* const res = await client.v1.aiQrCodeGenerator.generate(
|
|
21
|
+
* {
|
|
22
|
+
* content: "https://magichour.ai",
|
|
23
|
+
* name: "Qr Code image",
|
|
24
|
+
* style: { artStyle: "Watercolor" },
|
|
25
|
+
* },
|
|
26
|
+
* {
|
|
27
|
+
* waitForCompletion: true,
|
|
28
|
+
* downloadOutputs: true,
|
|
29
|
+
* downloadDirectory: "outputs",
|
|
30
|
+
* },
|
|
31
|
+
* );
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../image-projects/resource-client").V1ImageProjectsGetResponseWithDownloads>;
|
|
6
35
|
/**
|
|
7
36
|
* AI QR Code
|
|
8
37
|
*
|
|
@@ -12,3 +41,4 @@ export declare class AiQrCodeGeneratorClient extends CoreResourceClient {
|
|
|
12
41
|
*/
|
|
13
42
|
create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiQrCodeGeneratorCreateResponse>;
|
|
14
43
|
}
|
|
44
|
+
export {};
|