magic-hour 0.56.1 → 0.57.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 CHANGED
@@ -301,6 +301,10 @@ Valid values are: `none`, `error`, `warn`, `info`, `debug` (case insensitive). I
301
301
 
302
302
  - [create](src/resources/v1/files/upload-urls/README.md#create) - Generate asset upload urls
303
303
 
304
+ ### [v1.headSwap](src/resources/v1/head-swap/README.md)
305
+
306
+ - [create](src/resources/v1/head-swap/README.md#create) - Head Swap
307
+
304
308
  ### [v1.imageBackgroundRemover](src/resources/v1/image-background-remover/README.md)
305
309
 
306
310
  - [create](src/resources/v1/image-background-remover/README.md#create) - Image Background Remover
@@ -1,4 +1,4 @@
1
1
  export declare enum Environment {
2
2
  Environment = "https://api.magichour.ai",
3
- MockServer = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.57.1"
3
+ MockServer = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.58.0"
4
4
  }
@@ -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.57.1";
7
+ Environment["MockServer"] = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.58.0";
8
8
  })(Environment || (exports.Environment = Environment = {}));
@@ -0,0 +1,2 @@
1
+ export { CreateRequest } from "./request-types";
2
+ export { HeadSwapClient } from "./resource-client";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HeadSwapClient = void 0;
4
+ var resource_client_1 = require("./resource-client");
5
+ Object.defineProperty(exports, "HeadSwapClient", { enumerable: true, get: function () { return resource_client_1.HeadSwapClient; } });
@@ -0,0 +1,33 @@
1
+ import * as z from "zod";
2
+ import { External$V1HeadSwapCreateBodyAssets, V1HeadSwapCreateBodyAssets } from "../../../types/v1-head-swap-create-body-assets";
3
+ /**
4
+ * CreateRequest
5
+ */
6
+ export type CreateRequest = {
7
+ /**
8
+ * Provide the body and head images for head swap
9
+ */
10
+ assets: V1HeadSwapCreateBodyAssets;
11
+ /**
12
+ * Constrains the larger dimension (height or width) of the output. Omit to use the maximum allowed for your plan (capped at 2048px). Values above your plan maximum are clamped down to your plan's maximum.
13
+ */
14
+ maxResolution?: number | undefined;
15
+ /**
16
+ * Give your image a custom name for easy identification.
17
+ */
18
+ name?: string | undefined;
19
+ };
20
+ /**
21
+ * @internal
22
+ * CreateRequest without any key transformation, this is what
23
+ * we expect to come in as network data
24
+ */
25
+ export type External$CreateRequest = {
26
+ assets: External$V1HeadSwapCreateBodyAssets;
27
+ max_resolution?: number | undefined;
28
+ name?: string | undefined;
29
+ };
30
+ export declare const Schemas$CreateRequest: {
31
+ in: z.ZodType<CreateRequest, z.ZodTypeDef, unknown>;
32
+ out: z.ZodType<External$CreateRequest, z.ZodTypeDef, CreateRequest>;
33
+ };
@@ -0,0 +1,76 @@
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_head_swap_create_body_assets_1 = require("../../../types/v1-head-swap-create-body-assets");
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_head_swap_create_body_assets_1.Schemas$V1HeadSwapCreateBodyAssets.in,
46
+ max_resolution: z.number().int().optional(),
47
+ name: z.string().optional(),
48
+ })
49
+ .transform((obj) => {
50
+ return (0, make_api_request_js_1.zodTransform)(obj, {
51
+ assets: "assets",
52
+ max_resolution: "maxResolution",
53
+ name: "name",
54
+ });
55
+ });
56
+ /**
57
+ * @internal
58
+ * Takes typescript data, validates it, and maps keys to match the expected external object External$CreateRequest
59
+ */
60
+ const SchemaOut$CreateRequest = z
61
+ .object({
62
+ assets: v1_head_swap_create_body_assets_1.Schemas$V1HeadSwapCreateBodyAssets.out,
63
+ maxResolution: z.number().int().optional(),
64
+ name: z.string().optional(),
65
+ })
66
+ .transform((obj) => {
67
+ return (0, make_api_request_js_1.zodTransform)(obj, {
68
+ assets: "assets",
69
+ maxResolution: "max_resolution",
70
+ name: "name",
71
+ });
72
+ });
73
+ exports.Schemas$CreateRequest = {
74
+ in: SchemaIn$CreateRequest,
75
+ out: SchemaOut$CreateRequest,
76
+ };
@@ -0,0 +1,64 @@
1
+ import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "make-api-request-js";
2
+ import { GenerateOptions, GenerateRequestType } from "../../../helpers/generate-type";
3
+ import * as requests from "../../../resources/v1/head-swap/request-types";
4
+ import * as types from "../../../types";
5
+ type GenerateRequest = GenerateRequestType<requests.CreateRequest, {
6
+ /**
7
+ * Image that receives the swapped head. 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
+ bodyFilePath: string;
14
+ /**
15
+ * Image of the head to place on the body. This value is either
16
+ * - a direct URL to the image file
17
+ * - a path to a local file
18
+ *
19
+ * 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.
20
+ */
21
+ headFilePath: string;
22
+ }>;
23
+ export declare class HeadSwapClient extends CoreResourceClient {
24
+ constructor(coreClient: CoreClient, opts: ResourceClientOptions);
25
+ /**
26
+ * Head Swap
27
+ *
28
+ * Swap a head onto a body image
29
+ *
30
+ * This method provides a convenient way to create a request and automatically wait for completion and download outputs.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * import { Client } from "../../../index.js";
35
+ *
36
+ * const client = new Client({ token: process.env["API_TOKEN"]!! });
37
+ * const res = await client.v1.headSwap.generate(
38
+ * {
39
+ * assets: {
40
+ * bodyFilePath: "/path/to/body.png",
41
+ * headFilePath: "/path/to/head.png",
42
+ * },
43
+ * maxResolution: 1024,
44
+ * name: "My Head Swap image",
45
+ * },
46
+ * {
47
+ * waitForCompletion: true,
48
+ * downloadOutputs: true,
49
+ * downloadDirectory: ".",
50
+ * },
51
+ * );
52
+ * ```
53
+ */
54
+ generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../image-projects/resource-client").V1ImageProjectsGetResponseWithDownloads>;
55
+ /**
56
+ * Head Swap
57
+ *
58
+ * Swap a head onto a body image. Each image costs 10 credits. Output resolution depends on your subscription; you may set `max_resolution` lower than your plan maximum if desired.
59
+ *
60
+ * POST /v1/head-swap
61
+ */
62
+ create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1HeadSwapCreateResponse>;
63
+ }
64
+ export {};
@@ -0,0 +1,105 @@
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.HeadSwapClient = void 0;
24
+ const make_api_request_js_1 = require("make-api-request-js");
25
+ const logger_1 = require("../../../logger");
26
+ const files_1 = require("../../../resources/v1/files");
27
+ const image_projects_1 = require("../../../resources/v1/image-projects");
28
+ const v1_head_swap_create_body_1 = require("../../../types/v1-head-swap-create-body");
29
+ const v1_head_swap_create_response_1 = require("../../../types/v1-head-swap-create-response");
30
+ class HeadSwapClient extends make_api_request_js_1.CoreResourceClient {
31
+ constructor(coreClient, opts) {
32
+ super(coreClient, opts);
33
+ }
34
+ /**
35
+ * Head Swap
36
+ *
37
+ * Swap a head onto a body image
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.headSwap.generate(
47
+ * {
48
+ * assets: {
49
+ * bodyFilePath: "/path/to/body.png",
50
+ * headFilePath: "/path/to/head.png",
51
+ * },
52
+ * maxResolution: 1024,
53
+ * name: "My Head Swap image",
54
+ * },
55
+ * {
56
+ * waitForCompletion: true,
57
+ * downloadOutputs: true,
58
+ * downloadDirectory: ".",
59
+ * },
60
+ * );
61
+ * ```
62
+ */
63
+ generate(request_1) {
64
+ return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
65
+ const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
66
+ const fileClient = new files_1.FilesClient(this._client, this._opts);
67
+ const _a = request.assets, { bodyFilePath, headFilePath } = _a, restAssets = __rest(_a, ["bodyFilePath", "headFilePath"]);
68
+ (0, logger_1.getLogger)().debug(`Uploading file ${bodyFilePath} to Magic Hour's storage`);
69
+ (0, logger_1.getLogger)().debug(`Uploading file ${headFilePath} to Magic Hour's storage`);
70
+ const [uploadedBodyFilePath, uploadedHeadFilePath] = yield Promise.all([
71
+ fileClient.uploadFile(bodyFilePath),
72
+ fileClient.uploadFile(headFilePath),
73
+ ]);
74
+ (0, logger_1.getLogger)().info(`Uploaded file ${bodyFilePath} to Magic Hour's storage as ${uploadedBodyFilePath}`);
75
+ (0, logger_1.getLogger)().info(`Uploaded file ${headFilePath} to Magic Hour's storage as ${uploadedHeadFilePath}`);
76
+ const createResponse = yield this.create(Object.assign(Object.assign({}, request), { assets: Object.assign(Object.assign({}, restAssets), { bodyFilePath: uploadedBodyFilePath, headFilePath: uploadedHeadFilePath }) }), createOpts);
77
+ (0, logger_1.getLogger)().info(`Created HeadSwapClient project ${createResponse.id}`);
78
+ const projectsClient = new image_projects_1.ImageProjectsClient(this._client, this._opts);
79
+ (0, logger_1.getLogger)().debug(`Checking result for HeadSwapClient project ${createResponse.id}`);
80
+ const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
81
+ downloadOutputs,
82
+ downloadDirectory }, createOpts));
83
+ return result;
84
+ });
85
+ }
86
+ /**
87
+ * Head Swap
88
+ *
89
+ * Swap a head onto a body image. Each image costs 10 credits. Output resolution depends on your subscription; you may set `max_resolution` lower than your plan maximum if desired.
90
+ *
91
+ * POST /v1/head-swap
92
+ */
93
+ create(request, opts) {
94
+ return this._client.makeRequest({
95
+ method: "post",
96
+ path: "/v1/head-swap",
97
+ auth: ["bearerAuth"],
98
+ contentType: "application/json",
99
+ body: v1_head_swap_create_body_1.Schemas$V1HeadSwapCreateBody.out.parse(request),
100
+ responseSchema: v1_head_swap_create_response_1.Schemas$V1HeadSwapCreateResponse.in,
101
+ opts,
102
+ });
103
+ }
104
+ }
105
+ exports.HeadSwapClient = HeadSwapClient;
@@ -17,6 +17,7 @@ export * as faceDetection from "./face-detection";
17
17
  export * as faceSwap from "./face-swap";
18
18
  export * as faceSwapPhoto from "./face-swap-photo";
19
19
  export * as files from "./files";
20
+ export * as headSwap from "./head-swap";
20
21
  export * as imageBackgroundRemover from "./image-background-remover";
21
22
  export * as imageProjects from "./image-projects";
22
23
  export * as imageToVideo from "./image-to-video";
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.videoToVideo = exports.videoProjects = exports.textToVideo = exports.V1Client = exports.photoColorizer = exports.lipSync = exports.imageToVideo = exports.imageProjects = exports.imageBackgroundRemover = exports.files = exports.faceSwapPhoto = exports.faceSwap = exports.faceDetection = exports.autoSubtitleGenerator = exports.audioProjects = exports.animation = exports.aiVoiceGenerator = exports.aiVoiceCloner = exports.aiTalkingPhoto = exports.aiQrCodeGenerator = exports.aiMemeGenerator = exports.aiImageUpscaler = exports.aiImageGenerator = exports.aiImageEditor = exports.aiHeadshotGenerator = exports.aiGifGenerator = exports.aiFaceEditor = exports.aiClothesChanger = void 0;
36
+ exports.videoToVideo = exports.videoProjects = exports.textToVideo = exports.V1Client = exports.photoColorizer = exports.lipSync = exports.imageToVideo = exports.imageProjects = exports.imageBackgroundRemover = exports.headSwap = exports.files = exports.faceSwapPhoto = exports.faceSwap = exports.faceDetection = exports.autoSubtitleGenerator = exports.audioProjects = exports.animation = exports.aiVoiceGenerator = exports.aiVoiceCloner = exports.aiTalkingPhoto = exports.aiQrCodeGenerator = exports.aiMemeGenerator = exports.aiImageUpscaler = exports.aiImageGenerator = exports.aiImageEditor = exports.aiHeadshotGenerator = exports.aiGifGenerator = exports.aiFaceEditor = exports.aiClothesChanger = void 0;
37
37
  exports.aiClothesChanger = __importStar(require("./ai-clothes-changer"));
38
38
  exports.aiFaceEditor = __importStar(require("./ai-face-editor"));
39
39
  exports.aiGifGenerator = __importStar(require("./ai-gif-generator"));
@@ -53,6 +53,7 @@ exports.faceDetection = __importStar(require("./face-detection"));
53
53
  exports.faceSwap = __importStar(require("./face-swap"));
54
54
  exports.faceSwapPhoto = __importStar(require("./face-swap-photo"));
55
55
  exports.files = __importStar(require("./files"));
56
+ exports.headSwap = __importStar(require("./head-swap"));
56
57
  exports.imageBackgroundRemover = __importStar(require("./image-background-remover"));
57
58
  exports.imageProjects = __importStar(require("./image-projects"));
58
59
  exports.imageToVideo = __importStar(require("./image-to-video"));
@@ -18,6 +18,7 @@ import { FaceDetectionClient } from "../../resources/v1/face-detection";
18
18
  import { FaceSwapClient } from "../../resources/v1/face-swap";
19
19
  import { FaceSwapPhotoClient } from "../../resources/v1/face-swap-photo";
20
20
  import { FilesClient } from "../../resources/v1/files";
21
+ import { HeadSwapClient } from "../../resources/v1/head-swap";
21
22
  import { ImageBackgroundRemoverClient } from "../../resources/v1/image-background-remover";
22
23
  import { ImageProjectsClient } from "../../resources/v1/image-projects";
23
24
  import { ImageToVideoClient } from "../../resources/v1/image-to-video";
@@ -27,6 +28,7 @@ import { TextToVideoClient } from "../../resources/v1/text-to-video";
27
28
  import { VideoProjectsClient } from "../../resources/v1/video-projects";
28
29
  import { VideoToVideoClient } from "../../resources/v1/video-to-video";
29
30
  export declare class V1Client extends CoreResourceClient {
31
+ private _headSwapLazy?;
30
32
  private _aiVoiceClonerLazy?;
31
33
  private _audioProjectsLazy?;
32
34
  private _aiVoiceGeneratorLazy?;
@@ -82,4 +84,5 @@ export declare class V1Client extends CoreResourceClient {
82
84
  get aiVoiceGenerator(): AiVoiceGeneratorClient;
83
85
  get audioProjects(): AudioProjectsClient;
84
86
  get aiVoiceCloner(): AiVoiceClonerClient;
87
+ get headSwap(): HeadSwapClient;
85
88
  }
@@ -25,6 +25,7 @@ class V1Client extends make_api_request_js_1.CoreResourceClient {
25
25
  this.faceSwap;
26
26
  this.faceSwapPhoto;
27
27
  this.files;
28
+ this.headSwap;
28
29
  this.imageBackgroundRemover;
29
30
  this.imageProjects;
30
31
  this.imageToVideo;
@@ -166,5 +167,9 @@ class V1Client extends make_api_request_js_1.CoreResourceClient {
166
167
  return ((_a = this._aiVoiceClonerLazy) !== null && _a !== void 0 ? _a : (this._aiVoiceClonerLazy =
167
168
  new (require("./ai-voice-cloner").AiVoiceClonerClient)(this._client, this._opts)));
168
169
  }
170
+ get headSwap() {
171
+ var _a;
172
+ return ((_a = this._headSwapLazy) !== null && _a !== void 0 ? _a : (this._headSwapLazy = new (require("./head-swap").HeadSwapClient)(this._client, this._opts)));
173
+ }
169
174
  }
170
175
  exports.V1Client = V1Client;
@@ -98,6 +98,9 @@ export { V1FilesUploadUrlsCreateBodyItemsItem } from "./v1-files-upload-urls-cre
98
98
  export { V1FilesUploadUrlsCreateBodyItemsItemTypeEnum } from "./v1-files-upload-urls-create-body-items-item-type-enum";
99
99
  export { V1FilesUploadUrlsCreateResponse } from "./v1-files-upload-urls-create-response";
100
100
  export { V1FilesUploadUrlsCreateResponseItemsItem } from "./v1-files-upload-urls-create-response-items-item";
101
+ export { V1HeadSwapCreateBody } from "./v1-head-swap-create-body";
102
+ export { V1HeadSwapCreateBodyAssets } from "./v1-head-swap-create-body-assets";
103
+ export { V1HeadSwapCreateResponse } from "./v1-head-swap-create-response";
101
104
  export { V1ImageBackgroundRemoverCreateBody } from "./v1-image-background-remover-create-body";
102
105
  export { V1ImageBackgroundRemoverCreateBodyAssets } from "./v1-image-background-remover-create-body-assets";
103
106
  export { V1ImageBackgroundRemoverCreateResponse } from "./v1-image-background-remover-create-response";
@@ -0,0 +1,37 @@
1
+ import * as z from "zod";
2
+ /**
3
+ * Provide the body and head images for head swap
4
+ */
5
+ export type V1HeadSwapCreateBodyAssets = {
6
+ /**
7
+ * Image that receives the swapped head. This value is either
8
+ * - a direct URL to the video file
9
+ * - `file_path` field from the response of the [upload urls API](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls).
10
+ *
11
+ * See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details.
12
+ *
13
+ */
14
+ bodyFilePath: string;
15
+ /**
16
+ * Image of the head to place on the body. 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
+ * See the [file upload guide](https://docs.magichour.ai/api-reference/files/generate-asset-upload-urls#input-file) for details.
21
+ *
22
+ */
23
+ headFilePath: string;
24
+ };
25
+ /**
26
+ * @internal
27
+ * V1HeadSwapCreateBodyAssets without any key transformation, this is what
28
+ * we expect to come in as network data
29
+ */
30
+ export type External$V1HeadSwapCreateBodyAssets = {
31
+ body_file_path: string;
32
+ head_file_path: string;
33
+ };
34
+ export declare const Schemas$V1HeadSwapCreateBodyAssets: {
35
+ in: z.ZodType<V1HeadSwapCreateBodyAssets, z.ZodTypeDef, unknown>;
36
+ out: z.ZodType<External$V1HeadSwapCreateBodyAssets, z.ZodTypeDef, V1HeadSwapCreateBodyAssets>;
37
+ };
@@ -0,0 +1,71 @@
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$V1HeadSwapCreateBodyAssets = void 0;
37
+ const make_api_request_js_1 = require("make-api-request-js");
38
+ const z = __importStar(require("zod"));
39
+ /**
40
+ * Takes network data, validates it, and transforms keys to match typescript object V1HeadSwapCreateBodyAssets
41
+ */
42
+ const SchemaIn$V1HeadSwapCreateBodyAssets = z
43
+ .object({
44
+ body_file_path: z.string(),
45
+ head_file_path: z.string(),
46
+ })
47
+ .transform((obj) => {
48
+ return (0, make_api_request_js_1.zodTransform)(obj, {
49
+ body_file_path: "bodyFilePath",
50
+ head_file_path: "headFilePath",
51
+ });
52
+ });
53
+ /**
54
+ * @internal
55
+ * Takes typescript data, validates it, and maps keys to match the expected external object External$V1HeadSwapCreateBodyAssets
56
+ */
57
+ const SchemaOut$V1HeadSwapCreateBodyAssets = z
58
+ .object({
59
+ bodyFilePath: z.string(),
60
+ headFilePath: z.string(),
61
+ })
62
+ .transform((obj) => {
63
+ return (0, make_api_request_js_1.zodTransform)(obj, {
64
+ bodyFilePath: "body_file_path",
65
+ headFilePath: "head_file_path",
66
+ });
67
+ });
68
+ exports.Schemas$V1HeadSwapCreateBodyAssets = {
69
+ in: SchemaIn$V1HeadSwapCreateBodyAssets,
70
+ out: SchemaOut$V1HeadSwapCreateBodyAssets,
71
+ };
@@ -0,0 +1,33 @@
1
+ import * as z from "zod";
2
+ import { External$V1HeadSwapCreateBodyAssets, V1HeadSwapCreateBodyAssets } from "./v1-head-swap-create-body-assets";
3
+ /**
4
+ * V1HeadSwapCreateBody
5
+ */
6
+ export type V1HeadSwapCreateBody = {
7
+ /**
8
+ * Provide the body and head images for head swap
9
+ */
10
+ assets: V1HeadSwapCreateBodyAssets;
11
+ /**
12
+ * Constrains the larger dimension (height or width) of the output. Omit to use the maximum allowed for your plan (capped at 2048px). Values above your plan maximum are clamped down to your plan's maximum.
13
+ */
14
+ maxResolution?: number | undefined;
15
+ /**
16
+ * Give your image a custom name for easy identification.
17
+ */
18
+ name?: string | undefined;
19
+ };
20
+ /**
21
+ * @internal
22
+ * V1HeadSwapCreateBody without any key transformation, this is what
23
+ * we expect to come in as network data
24
+ */
25
+ export type External$V1HeadSwapCreateBody = {
26
+ assets: External$V1HeadSwapCreateBodyAssets;
27
+ max_resolution?: number | undefined;
28
+ name?: string | undefined;
29
+ };
30
+ export declare const Schemas$V1HeadSwapCreateBody: {
31
+ in: z.ZodType<V1HeadSwapCreateBody, z.ZodTypeDef, unknown>;
32
+ out: z.ZodType<External$V1HeadSwapCreateBody, z.ZodTypeDef, V1HeadSwapCreateBody>;
33
+ };
@@ -0,0 +1,76 @@
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$V1HeadSwapCreateBody = void 0;
37
+ const make_api_request_js_1 = require("make-api-request-js");
38
+ const z = __importStar(require("zod"));
39
+ const v1_head_swap_create_body_assets_1 = require("./v1-head-swap-create-body-assets");
40
+ /**
41
+ * Takes network data, validates it, and transforms keys to match typescript object V1HeadSwapCreateBody
42
+ */
43
+ const SchemaIn$V1HeadSwapCreateBody = z
44
+ .object({
45
+ assets: v1_head_swap_create_body_assets_1.Schemas$V1HeadSwapCreateBodyAssets.in,
46
+ max_resolution: z.number().int().optional(),
47
+ name: z.string().optional(),
48
+ })
49
+ .transform((obj) => {
50
+ return (0, make_api_request_js_1.zodTransform)(obj, {
51
+ assets: "assets",
52
+ max_resolution: "maxResolution",
53
+ name: "name",
54
+ });
55
+ });
56
+ /**
57
+ * @internal
58
+ * Takes typescript data, validates it, and maps keys to match the expected external object External$V1HeadSwapCreateBody
59
+ */
60
+ const SchemaOut$V1HeadSwapCreateBody = z
61
+ .object({
62
+ assets: v1_head_swap_create_body_assets_1.Schemas$V1HeadSwapCreateBodyAssets.out,
63
+ maxResolution: z.number().int().optional(),
64
+ name: z.string().optional(),
65
+ })
66
+ .transform((obj) => {
67
+ return (0, make_api_request_js_1.zodTransform)(obj, {
68
+ assets: "assets",
69
+ maxResolution: "max_resolution",
70
+ name: "name",
71
+ });
72
+ });
73
+ exports.Schemas$V1HeadSwapCreateBody = {
74
+ in: SchemaIn$V1HeadSwapCreateBody,
75
+ out: SchemaOut$V1HeadSwapCreateBody,
76
+ };
@@ -0,0 +1,34 @@
1
+ import * as z from "zod";
2
+ /**
3
+ * Success
4
+ */
5
+ export type V1HeadSwapCreateResponse = {
6
+ /**
7
+ * The amount of credits deducted from your account to generate the image. We charge credits right when the request is made.
8
+ *
9
+ * If an error occurred while generating the image(s), credits will be refunded and this field will be updated to include the refund.
10
+ */
11
+ creditsCharged: number;
12
+ /**
13
+ * Deprecated: Previously represented the number of frames (original name of our credit system) used for image generation. Use 'credits_charged' instead.
14
+ */
15
+ frameCost: number;
16
+ /**
17
+ * Unique ID of the image. Use it with the [Get image Project API](https://docs.magichour.ai/api-reference/image-projects/get-image-details) to fetch status and downloads.
18
+ */
19
+ id: string;
20
+ };
21
+ /**
22
+ * @internal
23
+ * V1HeadSwapCreateResponse without any key transformation, this is what
24
+ * we expect to come in as network data
25
+ */
26
+ export type External$V1HeadSwapCreateResponse = {
27
+ credits_charged: number;
28
+ frame_cost: number;
29
+ id: string;
30
+ };
31
+ export declare const Schemas$V1HeadSwapCreateResponse: {
32
+ in: z.ZodType<V1HeadSwapCreateResponse, z.ZodTypeDef, unknown>;
33
+ out: z.ZodType<External$V1HeadSwapCreateResponse, z.ZodTypeDef, V1HeadSwapCreateResponse>;
34
+ };
@@ -0,0 +1,75 @@
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$V1HeadSwapCreateResponse = void 0;
37
+ const make_api_request_js_1 = require("make-api-request-js");
38
+ const z = __importStar(require("zod"));
39
+ /**
40
+ * Takes network data, validates it, and transforms keys to match typescript object V1HeadSwapCreateResponse
41
+ */
42
+ const SchemaIn$V1HeadSwapCreateResponse = z
43
+ .object({
44
+ credits_charged: z.number().int(),
45
+ frame_cost: z.number().int(),
46
+ id: z.string(),
47
+ })
48
+ .transform((obj) => {
49
+ return (0, make_api_request_js_1.zodTransform)(obj, {
50
+ credits_charged: "creditsCharged",
51
+ frame_cost: "frameCost",
52
+ id: "id",
53
+ });
54
+ });
55
+ /**
56
+ * @internal
57
+ * Takes typescript data, validates it, and maps keys to match the expected external object External$V1HeadSwapCreateResponse
58
+ */
59
+ const SchemaOut$V1HeadSwapCreateResponse = z
60
+ .object({
61
+ creditsCharged: z.number().int(),
62
+ frameCost: z.number().int(),
63
+ id: z.string(),
64
+ })
65
+ .transform((obj) => {
66
+ return (0, make_api_request_js_1.zodTransform)(obj, {
67
+ creditsCharged: "credits_charged",
68
+ frameCost: "frame_cost",
69
+ id: "id",
70
+ });
71
+ });
72
+ exports.Schemas$V1HeadSwapCreateResponse = {
73
+ in: SchemaIn$V1HeadSwapCreateResponse,
74
+ out: SchemaOut$V1HeadSwapCreateResponse,
75
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-hour",
3
- "version": "0.56.1",
3
+ "version": "0.57.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {