magic-hour 0.40.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +10 -0
  2. package/dist/environment.d.ts +1 -1
  3. package/dist/environment.js +1 -1
  4. package/dist/resources/v1/ai-voice-generator/index.d.ts +2 -0
  5. package/dist/resources/v1/ai-voice-generator/index.js +5 -0
  6. package/dist/resources/v1/ai-voice-generator/request-types.d.ts +28 -0
  7. package/dist/resources/v1/ai-voice-generator/request-types.js +72 -0
  8. package/dist/resources/v1/ai-voice-generator/resource-client.d.ts +43 -0
  9. package/dist/resources/v1/ai-voice-generator/resource-client.js +90 -0
  10. package/dist/resources/v1/audio-projects/index.d.ts +2 -0
  11. package/dist/resources/v1/audio-projects/index.js +5 -0
  12. package/dist/resources/v1/audio-projects/request-types.d.ts +43 -0
  13. package/dist/resources/v1/audio-projects/request-types.js +96 -0
  14. package/dist/resources/v1/audio-projects/resource-client.d.ts +53 -0
  15. package/dist/resources/v1/audio-projects/resource-client.js +119 -0
  16. package/dist/resources/v1/audio-projects/resource-client.test.d.ts +1 -0
  17. package/dist/resources/v1/audio-projects/resource-client.test.js +552 -0
  18. package/dist/resources/v1/index.d.ts +2 -0
  19. package/dist/resources/v1/index.js +3 -1
  20. package/dist/resources/v1/lip-sync/request-types.d.ts +6 -0
  21. package/dist/resources/v1/lip-sync/request-types.js +5 -0
  22. package/dist/resources/v1/resource-client.d.ts +6 -0
  23. package/dist/resources/v1/resource-client.js +12 -0
  24. package/dist/types/index.d.ts +10 -0
  25. package/dist/types/v1-ai-talking-photo-create-body-style-generation-mode-enum.d.ts +5 -3
  26. package/dist/types/v1-ai-talking-photo-create-body-style.d.ts +6 -4
  27. package/dist/types/v1-ai-talking-photo-create-body-style.js +6 -2
  28. package/dist/types/v1-ai-voice-generator-create-body-style-voice-name-enum.d.ts +4 -0
  29. package/dist/types/v1-ai-voice-generator-create-body-style-voice-name-enum.js +2 -0
  30. package/dist/types/v1-ai-voice-generator-create-body-style.d.ts +27 -0
  31. package/dist/types/v1-ai-voice-generator-create-body-style.js +93 -0
  32. package/dist/types/v1-ai-voice-generator-create-body.d.ts +28 -0
  33. package/dist/types/v1-ai-voice-generator-create-body.js +72 -0
  34. package/dist/types/v1-ai-voice-generator-create-response.d.ts +29 -0
  35. package/dist/types/v1-ai-voice-generator-create-response.js +71 -0
  36. package/dist/types/v1-audio-projects-get-response-downloads-item.d.ts +21 -0
  37. package/dist/types/v1-audio-projects-get-response-downloads-item.js +71 -0
  38. package/dist/types/v1-audio-projects-get-response-error.d.ts +27 -0
  39. package/dist/types/v1-audio-projects-get-response-error.js +71 -0
  40. package/dist/types/v1-audio-projects-get-response-status-enum.d.ts +4 -0
  41. package/dist/types/v1-audio-projects-get-response-status-enum.js +2 -0
  42. package/dist/types/v1-audio-projects-get-response.d.ts +60 -0
  43. package/dist/types/v1-audio-projects-get-response.js +115 -0
  44. package/dist/types/v1-lip-sync-create-body-style-generation-mode-enum.d.ts +10 -0
  45. package/dist/types/v1-lip-sync-create-body-style-generation-mode-enum.js +2 -0
  46. package/dist/types/v1-lip-sync-create-body-style.d.ts +28 -0
  47. package/dist/types/v1-lip-sync-create-body-style.js +67 -0
  48. package/dist/types/v1-lip-sync-create-body.d.ts +6 -0
  49. package/dist/types/v1-lip-sync-create-body.js +5 -0
  50. package/dist/types/v1-video-to-video-create-body-style-art-style-enum.d.ts +1 -1
  51. package/dist/types/v1-video-to-video-create-body-style.d.ts +10 -10
  52. package/dist/types/v1-video-to-video-create-body-style.js +16 -18
  53. package/package.json +1 -1
package/README.md CHANGED
@@ -257,11 +257,21 @@ Valid values are: `none`, `error`, `warn`, `info`, `debug` (case insensitive). I
257
257
  * [create](src/resources/v1/ai-talking-photo/README.md#create) - AI Talking Photo
258
258
  * [generate](src/resources/v1/ai-talking-photo/README.md#generate) - AI Talking Photo Generate Workflow
259
259
 
260
+ ### [v1.aiVoiceGenerator](src/resources/v1/ai-voice-generator/README.md)
261
+
262
+ * [create](src/resources/v1/ai-voice-generator/README.md#create) - AI Voice Generator
263
+ * [generate](src/resources/v1/ai-voice-generator/README.md#generate) - AI Voice Generator Generate Workflow
264
+
260
265
  ### [v1.animation](src/resources/v1/animation/README.md)
261
266
 
262
267
  * [create](src/resources/v1/animation/README.md#create) - Animation
263
268
  * [generate](src/resources/v1/animation/README.md#generate) - Animation Generate Workflow
264
269
 
270
+ ### [v1.audioProjects](src/resources/v1/audio-projects/README.md)
271
+
272
+ * [delete](src/resources/v1/audio-projects/README.md#delete) - Delete audio
273
+ * [get](src/resources/v1/audio-projects/README.md#get) - Get audio details
274
+
265
275
  ### [v1.autoSubtitleGenerator](src/resources/v1/auto-subtitle-generator/README.md)
266
276
 
267
277
  * [create](src/resources/v1/auto-subtitle-generator/README.md#create) - Auto Subtitle Generator
@@ -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.39.1"
3
+ MockServer = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.41.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.39.1";
7
+ Environment["MockServer"] = "https://api.sideko.dev/v1/mock/magichour/magic-hour/0.41.0";
8
8
  })(Environment || (exports.Environment = Environment = {}));
@@ -0,0 +1,2 @@
1
+ export { CreateRequest } from "./request-types";
2
+ export { AiVoiceGeneratorClient } from "./resource-client";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AiVoiceGeneratorClient = void 0;
4
+ var resource_client_1 = require("./resource-client");
5
+ Object.defineProperty(exports, "AiVoiceGeneratorClient", { enumerable: true, get: function () { return resource_client_1.AiVoiceGeneratorClient; } });
@@ -0,0 +1,28 @@
1
+ import * as z from "zod";
2
+ import { External$V1AiVoiceGeneratorCreateBodyStyle, V1AiVoiceGeneratorCreateBodyStyle } from "../../../types/v1-ai-voice-generator-create-body-style";
3
+ /**
4
+ * CreateRequest
5
+ */
6
+ export type CreateRequest = {
7
+ /**
8
+ * The name of audio. This value is mainly used for your own identification of the audio.
9
+ */
10
+ name?: string | undefined;
11
+ /**
12
+ * The content used to generate speech.
13
+ */
14
+ style: V1AiVoiceGeneratorCreateBodyStyle;
15
+ };
16
+ /**
17
+ * @internal
18
+ * CreateRequest without any key transformation, this is what
19
+ * we expect to come in as network data
20
+ */
21
+ export type External$CreateRequest = {
22
+ name?: string | undefined;
23
+ style: External$V1AiVoiceGeneratorCreateBodyStyle;
24
+ };
25
+ export declare const Schemas$CreateRequest: {
26
+ in: z.ZodType<CreateRequest, z.ZodTypeDef, unknown>;
27
+ out: z.ZodType<External$CreateRequest, z.ZodTypeDef, CreateRequest>;
28
+ };
@@ -0,0 +1,72 @@
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_voice_generator_create_body_style_1 = require("../../../types/v1-ai-voice-generator-create-body-style");
40
+ /**
41
+ * Takes network data, validates it, and transforms keys to match typescript object CreateRequest
42
+ */
43
+ const SchemaIn$CreateRequest = z
44
+ .object({
45
+ name: z.string().optional(),
46
+ style: v1_ai_voice_generator_create_body_style_1.Schemas$V1AiVoiceGeneratorCreateBodyStyle.in,
47
+ })
48
+ .transform((obj) => {
49
+ return (0, make_api_request_js_1.zodTransform)(obj, {
50
+ name: "name",
51
+ style: "style",
52
+ });
53
+ });
54
+ /**
55
+ * @internal
56
+ * Takes typescript data, validates it, and maps keys to match the expected external object External$CreateRequest
57
+ */
58
+ const SchemaOut$CreateRequest = z
59
+ .object({
60
+ name: z.string().optional(),
61
+ style: v1_ai_voice_generator_create_body_style_1.Schemas$V1AiVoiceGeneratorCreateBodyStyle.out,
62
+ })
63
+ .transform((obj) => {
64
+ return (0, make_api_request_js_1.zodTransform)(obj, {
65
+ name: "name",
66
+ style: "style",
67
+ });
68
+ });
69
+ exports.Schemas$CreateRequest = {
70
+ in: SchemaIn$CreateRequest,
71
+ out: SchemaOut$CreateRequest,
72
+ };
@@ -0,0 +1,43 @@
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/ai-voice-generator/request-types";
4
+ import * as types from "../../../types";
5
+ type GenerateRequest = GenerateRequestType<requests.CreateRequest, {}>;
6
+ export declare class AiVoiceGeneratorClient extends CoreResourceClient {
7
+ constructor(coreClient: CoreClient, opts: ResourceClientOptions);
8
+ /**
9
+ * AI Voice Generator
10
+ *
11
+ * Generate speech from text
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.aiVoiceGenerator.generate(
21
+ * {
22
+ * name: "Voice Generator audio",
23
+ * style: { prompt: "Hello, how are you?", voiceName: "Elon Musk" },
24
+ * },
25
+ * {
26
+ * waitForCompletion: true,
27
+ * downloadOutputs: true,
28
+ * downloadDirectory: "outputs",
29
+ * },
30
+ * );
31
+ * ```
32
+ */
33
+ generate(request: GenerateRequest, opts?: GenerateOptions): Promise<import("../image-projects/resource-client").V1ImageProjectsGetResponseWithDownloads>;
34
+ /**
35
+ * AI Voice Generator
36
+ *
37
+ * Generate speech from text. Each character costs 0.05 credits. The cost is rounded up to the nearest whole number.
38
+ *
39
+ * POST /v1/ai-voice-generator
40
+ */
41
+ create(request: requests.CreateRequest, opts?: RequestOptions): ApiPromise<types.V1AiVoiceGeneratorCreateResponse>;
42
+ }
43
+ export {};
@@ -0,0 +1,90 @@
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.AiVoiceGeneratorClient = void 0;
24
+ const make_api_request_js_1 = require("make-api-request-js");
25
+ const logger_1 = require("../../../logger");
26
+ const image_projects_1 = require("../../../resources/v1/image-projects");
27
+ const v1_ai_voice_generator_create_body_1 = require("../../../types/v1-ai-voice-generator-create-body");
28
+ const v1_ai_voice_generator_create_response_1 = require("../../../types/v1-ai-voice-generator-create-response");
29
+ class AiVoiceGeneratorClient extends make_api_request_js_1.CoreResourceClient {
30
+ constructor(coreClient, opts) {
31
+ super(coreClient, opts);
32
+ }
33
+ /**
34
+ * AI Voice Generator
35
+ *
36
+ * Generate speech from text
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.aiVoiceGenerator.generate(
46
+ * {
47
+ * name: "Voice Generator audio",
48
+ * style: { prompt: "Hello, how are you?", voiceName: "Elon Musk" },
49
+ * },
50
+ * {
51
+ * waitForCompletion: true,
52
+ * downloadOutputs: true,
53
+ * downloadDirectory: "outputs",
54
+ * },
55
+ * );
56
+ * ```
57
+ */
58
+ generate(request_1) {
59
+ return __awaiter(this, arguments, void 0, function* (request, opts = {}) {
60
+ const { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = opts, createOpts = __rest(opts, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
61
+ const createResponse = yield this.create(request, createOpts);
62
+ (0, logger_1.getLogger)().info(`Created AiVoiceGeneratorClient project ${createResponse.id}`);
63
+ const projectsClient = new image_projects_1.ImageProjectsClient(this._client, this._opts);
64
+ (0, logger_1.getLogger)().debug(`Checking result for AiVoiceGeneratorClient project ${createResponse.id}`);
65
+ const result = yield projectsClient.checkResult({ id: createResponse.id }, Object.assign({ waitForCompletion,
66
+ downloadOutputs,
67
+ downloadDirectory }, createOpts));
68
+ return result;
69
+ });
70
+ }
71
+ /**
72
+ * AI Voice Generator
73
+ *
74
+ * Generate speech from text. Each character costs 0.05 credits. The cost is rounded up to the nearest whole number.
75
+ *
76
+ * POST /v1/ai-voice-generator
77
+ */
78
+ create(request, opts) {
79
+ return this._client.makeRequest({
80
+ method: "post",
81
+ path: "/v1/ai-voice-generator",
82
+ auth: ["bearerAuth"],
83
+ contentType: "application/json",
84
+ body: v1_ai_voice_generator_create_body_1.Schemas$V1AiVoiceGeneratorCreateBody.out.parse(request),
85
+ responseSchema: v1_ai_voice_generator_create_response_1.Schemas$V1AiVoiceGeneratorCreateResponse.in,
86
+ opts,
87
+ });
88
+ }
89
+ }
90
+ exports.AiVoiceGeneratorClient = AiVoiceGeneratorClient;
@@ -0,0 +1,2 @@
1
+ export { DeleteRequest, GetRequest } from "./request-types";
2
+ export { AudioProjectsClient } from "./resource-client";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AudioProjectsClient = void 0;
4
+ var resource_client_1 = require("./resource-client");
5
+ Object.defineProperty(exports, "AudioProjectsClient", { enumerable: true, get: function () { return resource_client_1.AudioProjectsClient; } });
@@ -0,0 +1,43 @@
1
+ import * as z from "zod";
2
+ /**
3
+ * DeleteRequest
4
+ */
5
+ export type DeleteRequest = {
6
+ /**
7
+ * Unique ID of the audio project. This value is returned by all of the POST APIs that create an audio.
8
+ */
9
+ id: string;
10
+ };
11
+ /**
12
+ * @internal
13
+ * DeleteRequest without any key transformation, this is what
14
+ * we expect to come in as network data
15
+ */
16
+ export type External$DeleteRequest = {
17
+ id: string;
18
+ };
19
+ export declare const Schemas$DeleteRequest: {
20
+ in: z.ZodType<DeleteRequest, z.ZodTypeDef, unknown>;
21
+ out: z.ZodType<External$DeleteRequest, z.ZodTypeDef, DeleteRequest>;
22
+ };
23
+ /**
24
+ * GetRequest
25
+ */
26
+ export type GetRequest = {
27
+ /**
28
+ * Unique ID of the audio project. This value is returned by all of the POST APIs that create an audio.
29
+ */
30
+ id: string;
31
+ };
32
+ /**
33
+ * @internal
34
+ * GetRequest without any key transformation, this is what
35
+ * we expect to come in as network data
36
+ */
37
+ export type External$GetRequest = {
38
+ id: string;
39
+ };
40
+ export declare const Schemas$GetRequest: {
41
+ in: z.ZodType<GetRequest, z.ZodTypeDef, unknown>;
42
+ out: z.ZodType<External$GetRequest, z.ZodTypeDef, GetRequest>;
43
+ };
@@ -0,0 +1,96 @@
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$GetRequest = exports.Schemas$DeleteRequest = 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 DeleteRequest
41
+ */
42
+ const SchemaIn$DeleteRequest = z
43
+ .object({
44
+ id: z.string(),
45
+ })
46
+ .transform((obj) => {
47
+ return (0, make_api_request_js_1.zodTransform)(obj, {
48
+ id: "id",
49
+ });
50
+ });
51
+ /**
52
+ * @internal
53
+ * Takes typescript data, validates it, and maps keys to match the expected external object External$DeleteRequest
54
+ */
55
+ const SchemaOut$DeleteRequest = z
56
+ .object({
57
+ id: z.string(),
58
+ })
59
+ .transform((obj) => {
60
+ return (0, make_api_request_js_1.zodTransform)(obj, {
61
+ id: "id",
62
+ });
63
+ });
64
+ exports.Schemas$DeleteRequest = {
65
+ in: SchemaIn$DeleteRequest,
66
+ out: SchemaOut$DeleteRequest,
67
+ };
68
+ /**
69
+ * Takes network data, validates it, and transforms keys to match typescript object GetRequest
70
+ */
71
+ const SchemaIn$GetRequest = z
72
+ .object({
73
+ id: z.string(),
74
+ })
75
+ .transform((obj) => {
76
+ return (0, make_api_request_js_1.zodTransform)(obj, {
77
+ id: "id",
78
+ });
79
+ });
80
+ /**
81
+ * @internal
82
+ * Takes typescript data, validates it, and maps keys to match the expected external object External$GetRequest
83
+ */
84
+ const SchemaOut$GetRequest = z
85
+ .object({
86
+ id: z.string(),
87
+ })
88
+ .transform((obj) => {
89
+ return (0, make_api_request_js_1.zodTransform)(obj, {
90
+ id: "id",
91
+ });
92
+ });
93
+ exports.Schemas$GetRequest = {
94
+ in: SchemaIn$GetRequest,
95
+ out: SchemaOut$GetRequest,
96
+ };
@@ -0,0 +1,53 @@
1
+ import { ApiPromise, CoreClient, CoreResourceClient, RequestOptions, ResourceClientOptions } from "make-api-request-js";
2
+ import { types } from "../../../index.js";
3
+ import { GenerateOptions } from "../../../helpers/generate-type";
4
+ import * as requests from "../../../resources/v1/audio-projects/request-types";
5
+ /**
6
+ * Extended response interface that includes downloaded paths
7
+ */
8
+ export interface V1AudioProjectsGetResponseWithDownloads extends types.V1AudioProjectsGetResponse {
9
+ /**
10
+ * The paths to the downloaded files.
11
+ * This field is only populated if `download_outputs` is True and the audio project is complete.
12
+ */
13
+ downloadedPaths?: string[];
14
+ }
15
+ export declare class AudioProjectsClient extends CoreResourceClient {
16
+ constructor(coreClient: CoreClient, opts: ResourceClientOptions);
17
+ /**
18
+ * Check the result of an audio project with optional waiting and downloading.
19
+ *
20
+ * This method retrieves the status of an audio project and optionally waits for completion
21
+ * and downloads the output files.
22
+ *
23
+ * @param request - Request object containing the audio project ID
24
+ * @param opts - Additional request options
25
+ * @returns The audio project response with optional downloaded file paths included
26
+ */
27
+ checkResult(request: requests.GetRequest, opts?: GenerateOptions): Promise<V1AudioProjectsGetResponseWithDownloads>;
28
+ /**
29
+ * Delete audio
30
+ *
31
+ * Permanently delete the rendered audio file(s). This action is not reversible, please be sure before deleting.
32
+ *
33
+ * DELETE /v1/audio-projects/{id}
34
+ */
35
+ delete(request: requests.DeleteRequest, opts?: RequestOptions): ApiPromise<null>;
36
+ /**
37
+ * Get audio details
38
+ *
39
+ * Get the details of a audio project. The `downloads` field will be empty unless the audio was successfully rendered.
40
+ *
41
+ * The audio can be one of the following status
42
+ * - `draft` - not currently used
43
+ * - `queued` - the job is queued and waiting for a GPU
44
+ * - `rendering` - the generation is in progress
45
+ * - `complete` - the audio is successful created
46
+ * - `error` - an error occurred during rendering
47
+ * - `canceled` - audio render is canceled by the user
48
+ *
49
+ *
50
+ * GET /v1/audio-projects/{id}
51
+ */
52
+ get(request: requests.GetRequest, opts?: RequestOptions): ApiPromise<types.V1AudioProjectsGetResponse>;
53
+ }
@@ -0,0 +1,119 @@
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.AudioProjectsClient = void 0;
24
+ const make_api_request_js_1 = require("make-api-request-js");
25
+ const download_1 = require("../../../helpers/download");
26
+ const sleep_1 = require("../../../helpers/sleep");
27
+ const logger_1 = require("../../../logger");
28
+ const v1_audio_projects_get_response_1 = require("../../../types/v1-audio-projects-get-response");
29
+ class AudioProjectsClient extends make_api_request_js_1.CoreResourceClient {
30
+ constructor(coreClient, opts) {
31
+ super(coreClient, opts);
32
+ }
33
+ /**
34
+ * Check the result of an audio project with optional waiting and downloading.
35
+ *
36
+ * This method retrieves the status of an audio project and optionally waits for completion
37
+ * and downloads the output files.
38
+ *
39
+ * @param request - Request object containing the audio project ID
40
+ * @param opts - Additional request options
41
+ * @returns The audio project response with optional downloaded file paths included
42
+ */
43
+ checkResult(request, opts) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ var _a, _b;
46
+ const _c = opts || {}, { waitForCompletion = true, downloadOutputs = true, downloadDirectory = undefined } = _c, requestOpts = __rest(_c, ["waitForCompletion", "downloadOutputs", "downloadDirectory"]);
47
+ let apiResponse = yield this.get({ id: request.id }, requestOpts);
48
+ if (!waitForCompletion) {
49
+ return Object.assign({}, apiResponse);
50
+ }
51
+ const pollInterval = parseFloat(process.env["MAGIC_HOUR_POLL_INTERVAL"] || "0.5");
52
+ (0, logger_1.getLogger)().debug(`Polling audio project ${request.id} every ${pollInterval} seconds`);
53
+ while (!["complete", "error", "canceled"].includes(apiResponse.status)) {
54
+ yield (0, sleep_1.sleep)(pollInterval * 1000); // Convert seconds to milliseconds
55
+ (0, logger_1.getLogger)().info(`Audio project ${request.id} status: ${apiResponse.status}, waiting for ${pollInterval} seconds and checking again`);
56
+ apiResponse = yield this.get({ id: request.id }, requestOpts);
57
+ }
58
+ if (apiResponse.status !== "complete") {
59
+ if (apiResponse.status === "error") {
60
+ const message = `Audio project ${request.id} has status ${apiResponse.status}: [${(_a = apiResponse.error) === null || _a === void 0 ? void 0 : _a.code}] ${(_b = apiResponse.error) === null || _b === void 0 ? void 0 : _b.message}`;
61
+ (0, logger_1.getLogger)().error(message);
62
+ }
63
+ else {
64
+ (0, logger_1.getLogger)().info(`Audio project ${request.id} has status ${apiResponse.status}. Stopping polling.`);
65
+ }
66
+ return Object.assign({}, apiResponse);
67
+ }
68
+ if (!downloadOutputs) {
69
+ (0, logger_1.getLogger)().info(`Download outputs is disabled. Returning audio project ${request.id} with status ${apiResponse.status}`);
70
+ return Object.assign({}, apiResponse);
71
+ }
72
+ (0, logger_1.getLogger)().debug(`Downloading outputs for audio project ${request.id} to ${downloadDirectory !== null && downloadDirectory !== void 0 ? downloadDirectory : "current directory"}`);
73
+ const downloadedPaths = yield (0, download_1.downloadFiles)(apiResponse.downloads, downloadDirectory);
74
+ (0, logger_1.getLogger)().info(`Downloaded outputs for audio project ${request.id} to ${downloadedPaths}`);
75
+ return Object.assign(Object.assign({}, apiResponse), { downloadedPaths });
76
+ });
77
+ }
78
+ /**
79
+ * Delete audio
80
+ *
81
+ * Permanently delete the rendered audio file(s). This action is not reversible, please be sure before deleting.
82
+ *
83
+ * DELETE /v1/audio-projects/{id}
84
+ */
85
+ delete(request, opts) {
86
+ return this._client.makeRequest({
87
+ method: "delete",
88
+ path: `/v1/audio-projects/${request.id}`,
89
+ auth: ["bearerAuth"],
90
+ opts,
91
+ });
92
+ }
93
+ /**
94
+ * Get audio details
95
+ *
96
+ * Get the details of a audio project. The `downloads` field will be empty unless the audio was successfully rendered.
97
+ *
98
+ * The audio can be one of the following status
99
+ * - `draft` - not currently used
100
+ * - `queued` - the job is queued and waiting for a GPU
101
+ * - `rendering` - the generation is in progress
102
+ * - `complete` - the audio is successful created
103
+ * - `error` - an error occurred during rendering
104
+ * - `canceled` - audio render is canceled by the user
105
+ *
106
+ *
107
+ * GET /v1/audio-projects/{id}
108
+ */
109
+ get(request, opts) {
110
+ return this._client.makeRequest({
111
+ method: "get",
112
+ path: `/v1/audio-projects/${request.id}`,
113
+ auth: ["bearerAuth"],
114
+ responseSchema: v1_audio_projects_get_response_1.Schemas$V1AudioProjectsGetResponse.in,
115
+ opts,
116
+ });
117
+ }
118
+ }
119
+ exports.AudioProjectsClient = AudioProjectsClient;