@mynthio/sdk 0.0.48 → 0.0.50

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.
@@ -76,12 +76,15 @@ declare namespace MynthSDKTypes {
76
76
  type TaskBase = {
77
77
  id: string;
78
78
  status: TaskStatus;
79
- apiKeyId: string | null;
80
- userId: string;
79
+ /** USD charged. Set once the task completes. */
81
80
  cost: string | null;
82
- createdAt: string;
83
- updatedAt: string;
84
- errors?: TaskError[];
81
+ /** Why the task failed. `null` unless `status` is `failed`. */
82
+ errors: TaskError[] | null;
83
+ user_id: string;
84
+ /** The API key that created the task. `null` for tasks created without one. */
85
+ api_key_id: string | null;
86
+ created_at: string;
87
+ updated_at: string;
85
88
  };
86
89
  type TaskError = {
87
90
  code: string;
@@ -149,35 +152,35 @@ declare namespace MynthSDKTypes {
149
152
  type ModelMode<Kind extends string = ImageModelInputKind | VideoModelInputKind> = {
150
153
  inputs?: {
151
154
  rules: ModelInputRule<Kind>[];
152
- maxTotal?: number;
155
+ max_total?: number;
153
156
  };
154
157
  };
155
158
  type ImageModelPricing = {
156
- perImage: {
159
+ per_image: {
157
160
  base: string;
158
161
  "4k"?: string;
159
162
  };
160
- perInput?: string;
163
+ per_input?: string;
161
164
  };
162
165
  type VideoModelPricing = {
163
166
  /** USD per second, keyed by resolution tier. Tiers the model cannot produce are absent. */
164
- perSecond: Partial<Record<VideoResolutionTier, string>>;
167
+ per_second: Partial<Record<VideoResolutionTier, string>>;
165
168
  /** Present only when audio is billed on top of the per-second video rate. */
166
169
  audio?: {
167
- perSecond: string;
170
+ per_second: string;
168
171
  };
169
172
  };
170
173
  type ModelPricing = ImageModelPricing | VideoModelPricing;
171
174
  type ImageModel = {
172
175
  id: string;
173
- displayName: string | null;
176
+ display_name: string | null;
174
177
  type: "image";
175
178
  modes: Partial<Record<"txt->img" | "img->img", ModelMode<ImageModelInputKind>>>;
176
179
  pricing: ImageModelPricing | null;
177
180
  };
178
181
  type VideoModel = {
179
182
  id: string;
180
- displayName: string | null;
183
+ display_name: string | null;
181
184
  type: "video";
182
185
  modes: Partial<Record<"txt->vid" | "img->vid", ModelMode<VideoModelInputKind>>>;
183
186
  pricing: VideoModelPricing | null;
@@ -201,14 +204,9 @@ declare namespace MynthSDKTypes {
201
204
  type ImageGenerationRequestCustomWebhook = {
202
205
  url: string;
203
206
  }[];
204
- type ImageGenerationRequestAccessPat = {
205
- enabled?: boolean;
206
- };
207
- type ImageGenerationRequestAccess = {
208
- pat: ImageGenerationRequestAccessPat;
209
- };
210
207
  type ImageGenerationRequestWebhook = {
211
- dashboard?: boolean;
208
+ /** `false` skips the webhooks registered on the account for this task. */
209
+ registered?: boolean;
212
210
  custom?: ImageGenerationRequestCustomWebhook;
213
211
  };
214
212
  type ImageGenerationRequestRatingLevel<T extends string = string> = {
@@ -224,12 +222,18 @@ declare namespace MynthSDKTypes {
224
222
  type ImageGenerationRequestAspectRatio = "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9" | "2:1" | "1:2";
225
223
  type ImageGenerationRequestSizeAspectRatio = {
226
224
  type: "aspect_ratio";
227
- aspectRatio: ImageGenerationRequestAspectRatio;
225
+ aspect_ratio: ImageGenerationRequestAspectRatio;
228
226
  scale?: ImageGenerationRequestSizeScale;
229
227
  };
230
228
  type ImageGenerationRequestSizeAuto = {
231
229
  type: "auto";
232
230
  };
231
+ type ImageFormat = "png" | "jpg" | "webp";
232
+ type ImageMimeType<FormatT extends ImageFormat = ImageFormat> = {
233
+ png: "image/png";
234
+ jpg: "image/jpeg";
235
+ webp: "image/webp";
236
+ }[FormatT];
233
237
  type ImageUploadInput = Blob | File;
234
238
  type ImageUploadResponse = {
235
239
  urls: string[];
@@ -261,7 +265,8 @@ declare namespace MynthSDKTypes {
261
265
  output?: ImageGenerationRequestOutput;
262
266
  webhook?: ImageGenerationRequestWebhook;
263
267
  rating?: ImageGenerationRequestRating;
264
- access?: ImageGenerationRequestAccess;
268
+ /** Return a public access token for browser-side polling. Defaults to `false`. */
269
+ generate_public_access_token?: boolean;
265
270
  inputs?: (string | ImageGenerationRequestInput)[];
266
271
  metadata?: Record<string, unknown>;
267
272
  destination?: string;
@@ -351,8 +356,8 @@ declare namespace MynthSDKTypes {
351
356
  };
352
357
  type ImageRateClientRequest = ImageClientUrlOrFile & (ImageRateRequestRatingDefault | ImageRateRequestRatingCustom);
353
358
  type ImageRateCreatedResponse = {
354
- taskId: string;
355
- estimatedCost: string;
359
+ task_id: string;
360
+ estimated_cost: string;
356
361
  };
357
362
  type ImageRateTaskResult<LevelT extends string = string> = {
358
363
  level: LevelT;
@@ -363,8 +368,8 @@ declare namespace MynthSDKTypes {
363
368
  };
364
369
  type ImageAltClientRequest = ImageClientUrlOrFile;
365
370
  type ImageAltCreatedResponse = {
366
- taskId: string;
367
- estimatedCost: string;
371
+ task_id: string;
372
+ estimated_cost: string;
368
373
  };
369
374
  type ImageAltTaskResult = {
370
375
  alt: string;
@@ -383,8 +388,8 @@ declare namespace MynthSDKTypes {
383
388
  effort?: ImageReviewEffort;
384
389
  };
385
390
  type ImageReviewCreatedResponse = {
386
- taskId: string;
387
- estimatedCost: string;
391
+ task_id: string;
392
+ estimated_cost: string;
388
393
  };
389
394
  type ImageReviewFinding = {
390
395
  /** What is wrong, in plain language. */
@@ -417,18 +422,13 @@ declare namespace MynthSDKTypes {
417
422
  url: string;
418
423
  output?: ImageRemoveBackgroundRequestOutput;
419
424
  webhook?: ImageGenerationRequestWebhook;
420
- access?: ImageGenerationRequestAccess;
425
+ /** Return a public access token for browser-side polling. Defaults to `false`. */
426
+ generate_public_access_token?: boolean;
421
427
  metadata?: Record<string, unknown>;
422
428
  destination?: string;
423
429
  };
424
430
  type ImageRemoveBackgroundClientRequest = ImageClientUrlOrFile & Omit<ImageRemoveBackgroundRequest, "url">;
425
- type ImageRemoveBackgroundCreatedResponse = {
426
- taskId: string;
427
- estimatedCost: string;
428
- access?: {
429
- publicAccessToken: string;
430
- };
431
- };
431
+ type ImageRemoveBackgroundCreatedResponse = TaskCreatedResponse;
432
432
  type ImageRemoveBackgroundResultImage = {
433
433
  id: string;
434
434
  /** Destination URL, or the Mynth URL without a destination. `null` when delivery failed. */
@@ -461,18 +461,13 @@ declare namespace MynthSDKTypes {
461
461
  effort: ImageUpscaleEffort;
462
462
  output?: ImageUpscaleRequestOutput;
463
463
  webhook?: ImageGenerationRequestWebhook;
464
- access?: ImageGenerationRequestAccess;
464
+ /** Return a public access token for browser-side polling. Defaults to `false`. */
465
+ generate_public_access_token?: boolean;
465
466
  metadata?: Record<string, unknown>;
466
467
  destination?: string;
467
468
  };
468
469
  type ImageUpscaleClientRequest = ImageClientUrlOrFile & Omit<ImageUpscaleRequest, "url">;
469
- type ImageUpscaleCreatedResponse = {
470
- taskId: string;
471
- estimatedCost: string;
472
- access?: {
473
- publicAccessToken: string;
474
- };
475
- };
470
+ type ImageUpscaleCreatedResponse = TaskCreatedResponse;
476
471
  type ImageUpscaleResultImage = {
477
472
  id: string;
478
473
  /** Destination URL, or the Mynth URL without a destination. `null` when delivery failed. */
@@ -490,7 +485,6 @@ declare namespace MynthSDKTypes {
490
485
  type VideoGenerationModel = VideoGenerationModelId;
491
486
  type VideoGenerationRequestResolution = "480p" | "720p" | "1080p" | "4k";
492
487
  type VideoGenerationRequestWebhook = ImageGenerationRequestWebhook;
493
- type VideoGenerationRequestAccess = ImageGenerationRequestAccess;
494
488
  type VideoGenerationRequestInputSource = {
495
489
  type: "url";
496
490
  url: string;
@@ -519,31 +513,26 @@ declare namespace MynthSDKTypes {
519
513
  audio?: boolean;
520
514
  inputs?: (string | VideoGenerationRequestInput)[];
521
515
  webhook?: VideoGenerationRequestWebhook;
522
- access?: VideoGenerationRequestAccess;
516
+ /** Return a public access token for browser-side polling. Defaults to `false`. */
517
+ generate_public_access_token?: boolean;
523
518
  metadata?: Record<string, unknown>;
524
519
  };
525
520
  type VideoGenerationClientRequest = Omit<VideoGenerationRequest, "inputs"> & {
526
521
  inputs?: (string | ImageUploadInput | VideoGenerationClientInput)[];
527
522
  };
528
- type VideoGenerationCreatedResponse = {
529
- taskId: string;
530
- /** Cost reserved for the task. Failed videos are refunded. */
531
- estimatedCost: string;
532
- access?: {
533
- publicAccessToken: string;
534
- };
535
- };
523
+ type VideoGenerationCreatedResponse = TaskCreatedResponse;
536
524
  type VideoGenerationEstimate = {
537
525
  /** Estimated cost in USD. Nothing is generated or charged. */
538
- estimatedCost: string;
526
+ estimated_cost: string;
539
527
  currency: "usd";
540
528
  /** Video generation always pins a model, so the estimate is exact. */
541
- estimateKind: "exact";
529
+ estimate_kind: "exact";
542
530
  };
543
531
  type VideoResultVideoSuccess = {
544
532
  status: "success";
545
533
  id: string;
546
- url: string;
534
+ /** Public URL of the video. `null` when it could not be delivered there. */
535
+ url: string | null;
547
536
  mynth_url: string;
548
537
  cost: string;
549
538
  /** Duration of the generated video in seconds */
@@ -564,119 +553,318 @@ declare namespace MynthSDKTypes {
564
553
  model: VideoGenerationModelId;
565
554
  videos: VideoResultVideo[];
566
555
  };
567
- type WebhookTaskImageCompletedPayload = {
568
- task: {
569
- id: string;
570
- };
571
- event: "task.image.generate.completed";
572
- result: ImageResult;
573
- request: ImageGenerationRequest;
574
- };
575
- type WebhookTaskImageFailedPayload = {
576
- task: {
577
- id: string;
578
- };
579
- event: "task.image.generate.failed";
580
- request: ImageGenerationRequest;
581
- errors: TaskError[];
582
- };
583
- type WebhookTaskImageRateCompletedPayload<LevelT extends string = string> = {
584
- task: {
585
- id: string;
586
- };
587
- event: "task.image.rate.completed";
588
- result: ImageRateTaskResult<LevelT>;
589
- request: ImageRateRequest;
590
- };
591
- type WebhookTaskImageRateFailedPayload = {
592
- task: {
593
- id: string;
594
- };
595
- event: "task.image.rate.failed";
596
- request: ImageRateRequest;
597
- errors: TaskError[];
598
- };
599
- type WebhookTaskImageAltCompletedPayload = {
600
- task: {
601
- id: string;
602
- };
603
- event: "task.image.alt.completed";
604
- result: ImageAltTaskResult;
605
- request: ImageAltRequest;
606
- };
607
- type WebhookTaskImageAltFailedPayload = {
608
- task: {
609
- id: string;
610
- };
611
- event: "task.image.alt.failed";
612
- request: ImageAltRequest;
556
+ type TaskCreatedResponse = {
557
+ task_id: string;
558
+ /** Cost reserved for the task. Failed media is refunded. */
559
+ estimated_cost: string;
560
+ /** Present when the request set `generate_public_access_token: true`. */
561
+ public_access_token?: string;
562
+ };
563
+ type CompletedTaskData<TypeT extends TaskType = TaskType> = Extract<TaskData, {
564
+ type: TypeT;
565
+ }> extends (infer DataT extends TaskData) ? DataT & {
566
+ status: "completed";
567
+ result: NonNullable<DataT["result"]>;
568
+ cost: string;
569
+ errors: null;
570
+ } : never;
571
+ type FailedTaskData<TypeT extends TaskType = TaskType> = Extract<TaskData, {
572
+ type: TypeT;
573
+ }> extends (infer DataT extends TaskData) ? DataT & {
574
+ status: "failed";
575
+ result: null;
613
576
  errors: TaskError[];
577
+ } : never;
578
+ type WebhookEventOf<TypeT extends TaskType, StatusT extends "completed" | "failed"> = {
579
+ id: string;
580
+ type: `task.${TypeT}.${StatusT}`;
581
+ timestamp: string;
582
+ data: StatusT extends "completed" ? CompletedTaskData<TypeT> : FailedTaskData<TypeT>;
614
583
  };
615
- type WebhookTaskImageReviewCompletedPayload = {
616
- task: {
617
- id: string;
618
- };
619
- event: "task.image.review.completed";
620
- result: ImageReviewTaskResult;
621
- request: ImageReviewRequest;
584
+ type WebhookEvent = { [TypeT in TaskType]: WebhookEventOf<TypeT, "completed"> | WebhookEventOf<TypeT, "failed">; }[TaskType];
585
+ type WebhookEventType = WebhookEvent["type"];
586
+ }
587
+ //#endregion
588
+ //#region src/task-result.d.ts
589
+ /**
590
+ * A completed task, as every result class is built from it. Polled task data
591
+ * and webhook events both come down to this shape.
592
+ */
593
+ type MynthCompletedTask<RequestT, ResultT> = {
594
+ taskId: string;
595
+ /** USD charged for the task */
596
+ cost: string;
597
+ request: RequestT;
598
+ result: ResultT;
599
+ };
600
+ type TaskFailureBase<RequestT> = {
601
+ /** The failed task's ID */
602
+ taskId: string;
603
+ /** Why the task failed. At least one entry. */
604
+ errors: MynthSDKTypes.TaskError[];
605
+ /** The request as the API echoed it */
606
+ raw: {
607
+ request: RequestT;
622
608
  };
623
- type WebhookTaskImageReviewFailedPayload = {
624
- task: {
625
- id: string;
626
- };
627
- event: "task.image.review.failed";
628
- request: ImageReviewRequest;
629
- errors: TaskError[];
609
+ };
610
+ /** Present only for task types whose request takes `metadata`. */
611
+ type TaskFailureMetadata<RequestT> = RequestT extends {
612
+ metadata?: infer MetadataT;
613
+ } ? "metadata" extends keyof RequestT ? {
614
+ /** Metadata attached to the request */
615
+ metadata: MetadataT | undefined;
616
+ } : unknown : unknown;
617
+ /**
618
+ * A failed task, as a `...Failed` webhook callback receives it.
619
+ *
620
+ * @template RequestT - The task type's request
621
+ */
622
+ type MynthTaskFailure<RequestT = unknown> = TaskFailureBase<RequestT> & TaskFailureMetadata<RequestT>;
623
+ //#endregion
624
+ //#region src/image-alt-result.d.ts
625
+ /**
626
+ * A completed image alt text task.
627
+ */
628
+ type ImageAltResult = {
629
+ /** The task ID created for this alt text request */
630
+ taskId: string;
631
+ /** Cost charged for the completed task */
632
+ cost: string;
633
+ /** Generated alt text */
634
+ alt: string;
635
+ /** The request and result as the API returned them, for fields the SDK does not map yet */
636
+ raw: {
637
+ request: MynthSDKTypes.ImageAltRequest;
638
+ result: MynthSDKTypes.ImageAltTaskResult;
630
639
  };
631
- type WebhookTaskImageRemoveBackgroundCompletedPayload = {
632
- task: {
633
- id: string;
634
- };
635
- event: "task.image.remove_background.completed";
636
- result: ImageRemoveBackgroundTaskResult;
637
- request: ImageRemoveBackgroundRequest;
640
+ };
641
+ //#endregion
642
+ //#region src/output-image.d.ts
643
+ /**
644
+ * An image produced by a Mynth task: generated, upscaled, or with its
645
+ * background removed.
646
+ *
647
+ * @template FormatT - Formats the task can deliver
648
+ */
649
+ type MynthOutputImage<FormatT extends MynthSDKTypes.ImageFormat = MynthSDKTypes.ImageFormat> = {
650
+ /** Image ID */
651
+ id: string;
652
+ /**
653
+ * Your destination's public URL for the image, or the Mynth CDN URL when the
654
+ * request named no destination. `null` when the destination upload failed or
655
+ * the destination has no public URL.
656
+ *
657
+ * The SDK never swaps in another URL for you: write `url ?? mynthUrl` where
658
+ * any URL will do.
659
+ */
660
+ url: string | null;
661
+ /** Mynth CDN URL. Always set, and served for 7 days. */
662
+ mynthUrl: string;
663
+ /** Width in pixels */
664
+ width: number;
665
+ /** Height in pixels */
666
+ height: number;
667
+ /** `{width}x{height}`, e.g. `"1024x768"` */
668
+ size: string;
669
+ /** File format the image was delivered in */
670
+ format: FormatT;
671
+ /** MIME type matching `format`, e.g. `"image/webp"` */
672
+ mimeType: MynthSDKTypes.ImageMimeType<FormatT>;
673
+ /** Delivery to your destination. `undefined` when the request named none. */
674
+ destination: MynthSDKTypes.ImageResultDestination | undefined;
675
+ };
676
+ //#endregion
677
+ //#region src/image-generation-result.d.ts
678
+ /**
679
+ * An image produced by image generation: an {@link MynthOutputImage} with its
680
+ * content rating.
681
+ *
682
+ * @template RatingT - Type of the rating, inferred from the request's `rating`
683
+ */
684
+ type MynthGeneratedImage<RatingT = MynthSDKTypes.ImageResultRating | undefined> = MynthOutputImage<MynthSDKTypes.ImageGenerationRequestOutputFormat> & {
685
+ /** Content rating. `undefined` when the request did not ask for one. */
686
+ rating: RatingT;
687
+ };
688
+ /**
689
+ * A completed image generation task.
690
+ *
691
+ * @template MetadataT - Type of the metadata attached to the request
692
+ * @template RatingT - Type of the rating response
693
+ */
694
+ type ImageGenerationResult<MetadataT = Record<string, unknown> | undefined, RatingT = MynthSDKTypes.ImageResultRating | undefined> = {
695
+ /** The task ID created for this request */
696
+ taskId: string;
697
+ /** Cost charged for the completed task */
698
+ cost: string;
699
+ /** Model that generated the images. Resolved to a concrete model when the request used `auto`. */
700
+ model: MynthSDKTypes.ImageGenerationModelId;
701
+ /** Successfully generated images, in order */
702
+ images: MynthGeneratedImage<RatingT>[];
703
+ /**
704
+ * Why images failed. A completed task can hold failed images; they are not
705
+ * in `images`.
706
+ */
707
+ failures: MynthSDKTypes.TaskError[];
708
+ /**
709
+ * The `url` of each successful image. Skips images whose `url` is `null`;
710
+ * read `images` to reach their `mynthUrl`.
711
+ */
712
+ urls: string[];
713
+ /** The prompt Mynth rewrote, when the request enabled `magic_prompt` */
714
+ magicPrompt: MynthSDKTypes.ImageResultMagicPrompt | undefined;
715
+ /** Metadata attached to the request */
716
+ metadata: MetadataT;
717
+ /** The request and result as the API returned them, for fields the SDK does not map yet */
718
+ raw: {
719
+ request: MynthSDKTypes.ImageGenerationRequest;
720
+ result: MynthSDKTypes.ImageResult;
638
721
  };
639
- type WebhookTaskImageRemoveBackgroundFailedPayload = {
640
- task: {
641
- id: string;
642
- };
643
- event: "task.image.remove_background.failed";
644
- request: ImageRemoveBackgroundRequest;
645
- errors: TaskError[];
722
+ };
723
+ //#endregion
724
+ //#region src/image-rate-result.d.ts
725
+ /**
726
+ * A completed image content rating task.
727
+ *
728
+ * @template LevelT - Union of possible rating level strings (e.g. `"sfw" | "nsfw"`)
729
+ */
730
+ type ImageRateResult<LevelT extends string = "sfw" | "nsfw"> = {
731
+ /** The task ID created for this rating request */
732
+ taskId: string;
733
+ /** Cost charged for the completed task */
734
+ cost: string;
735
+ /** Assigned rating level */
736
+ level: LevelT;
737
+ /** The request and result as the API returned them, for fields the SDK does not map yet */
738
+ raw: {
739
+ request: MynthSDKTypes.ImageRateRequest;
740
+ result: MynthSDKTypes.ImageRateTaskResult;
646
741
  };
647
- type WebhookTaskImageUpscaleCompletedPayload = {
648
- task: {
649
- id: string;
650
- };
651
- event: "task.image.upscale.completed";
652
- result: ImageUpscaleTaskResult;
653
- request: ImageUpscaleRequest;
742
+ };
743
+ //#endregion
744
+ //#region src/image-remove-background-result.d.ts
745
+ /**
746
+ * A completed image background removal task.
747
+ *
748
+ * @template MetadataT - Type of the metadata attached to the request
749
+ */
750
+ type ImageRemoveBackgroundResult<MetadataT = Record<string, unknown> | undefined> = {
751
+ /** The task ID created for this request */
752
+ taskId: string;
753
+ /** Cost charged for the completed task */
754
+ cost: string;
755
+ /** The image with its background removed */
756
+ image: MynthOutputImage<MynthSDKTypes.ImageRemoveBackgroundOutputFormat>;
757
+ /** Metadata attached to the request */
758
+ metadata: MetadataT;
759
+ /** The request and result as the API returned them, for fields the SDK does not map yet */
760
+ raw: {
761
+ request: MynthSDKTypes.ImageRemoveBackgroundRequest;
762
+ result: MynthSDKTypes.ImageRemoveBackgroundTaskResult;
654
763
  };
655
- type WebhookTaskImageUpscaleFailedPayload = {
656
- task: {
657
- id: string;
658
- };
659
- event: "task.image.upscale.failed";
660
- request: ImageUpscaleRequest;
661
- errors: TaskError[];
764
+ };
765
+ //#endregion
766
+ //#region src/image-review-result.d.ts
767
+ /**
768
+ * A completed image quality review task.
769
+ */
770
+ type ImageReviewResult = {
771
+ /** The task ID created for this review request */
772
+ taskId: string;
773
+ /** Cost charged for the completed task */
774
+ cost: string;
775
+ /** Median reviewer score from 1 to 4. Higher is better. */
776
+ score: number;
777
+ /** Review summary */
778
+ summary: string;
779
+ /** Defects found by the reviewer panel */
780
+ findings: MynthSDKTypes.ImageReviewFinding[];
781
+ /** Strengths identified by the reviewer panel */
782
+ strengths: MynthSDKTypes.ImageReviewStrength[];
783
+ /** The request and result as the API returned them, for fields the SDK does not map yet */
784
+ raw: {
785
+ request: MynthSDKTypes.ImageReviewRequest;
786
+ result: MynthSDKTypes.ImageReviewTaskResult;
662
787
  };
663
- type WebhookTaskVideoCompletedPayload = {
664
- task: {
665
- id: string;
666
- };
667
- event: "task.video.generate.completed";
668
- result: VideoResult;
669
- request: VideoGenerationRequest;
788
+ };
789
+ //#endregion
790
+ //#region src/image-upscale-result.d.ts
791
+ /**
792
+ * A completed image upscale task.
793
+ *
794
+ * @template MetadataT - Type of the metadata attached to the request
795
+ */
796
+ type ImageUpscaleResult<MetadataT = Record<string, unknown> | undefined> = {
797
+ /** The task ID created for this request */
798
+ taskId: string;
799
+ /** Cost charged for the completed task */
800
+ cost: string;
801
+ /** The upscaled image */
802
+ image: MynthOutputImage<MynthSDKTypes.ImageUpscaleOutputFormat>;
803
+ /** Metadata attached to the request */
804
+ metadata: MetadataT;
805
+ /** The request and result as the API returned them, for fields the SDK does not map yet */
806
+ raw: {
807
+ request: MynthSDKTypes.ImageUpscaleRequest;
808
+ result: MynthSDKTypes.ImageUpscaleTaskResult;
670
809
  };
671
- type WebhookTaskVideoFailedPayload = {
672
- task: {
673
- id: string;
674
- };
675
- event: "task.video.generate.failed";
676
- request: VideoGenerationRequest;
677
- errors: TaskError[];
810
+ };
811
+ //#endregion
812
+ //#region src/output-video.d.ts
813
+ /**
814
+ * A video produced by a Mynth video generation task.
815
+ */
816
+ type MynthOutputVideo = {
817
+ /** Video ID */
818
+ id: string;
819
+ /**
820
+ * Public URL of the video. `null` when it could not be delivered there.
821
+ * Write `url ?? mynthUrl` where any URL will do.
822
+ */
823
+ url: string | null;
824
+ /** Mynth CDN URL. Always set, and served for 7 days. */
825
+ mynthUrl: string;
826
+ /** Cost charged for this video */
827
+ cost: string;
828
+ /** Duration in seconds */
829
+ duration: number;
830
+ /** Resolution tier the video was rendered at */
831
+ resolution: MynthSDKTypes.VideoGenerationRequestResolution;
832
+ /** Whether the video has generated audio */
833
+ audio: boolean;
834
+ };
835
+ //#endregion
836
+ //#region src/video-generation-result.d.ts
837
+ /**
838
+ * A completed video generation task.
839
+ *
840
+ * @template MetadataT - Type of the metadata attached to the request
841
+ */
842
+ type VideoGenerationResult<MetadataT = Record<string, unknown> | undefined> = {
843
+ /** The task ID created for this request */
844
+ taskId: string;
845
+ /** Cost charged for the completed task. Failed videos are refunded. */
846
+ cost: string;
847
+ /** Model that generated the videos */
848
+ model: MynthSDKTypes.VideoGenerationModelId;
849
+ /** Successfully generated videos, in order */
850
+ videos: MynthOutputVideo[];
851
+ /**
852
+ * Why videos failed. A completed task can hold failed videos; they are not
853
+ * in `videos`.
854
+ */
855
+ failures: MynthSDKTypes.TaskError[];
856
+ /**
857
+ * The `url` of each successful video. Skips videos whose `url` is `null`;
858
+ * read `videos` to reach their `mynthUrl`.
859
+ */
860
+ urls: string[];
861
+ /** Metadata attached to the request */
862
+ metadata: MetadataT;
863
+ /** The request and result as the API returned them, for fields the SDK does not map yet */
864
+ raw: {
865
+ request: MynthSDKTypes.VideoGenerationRequest;
866
+ result: MynthSDKTypes.VideoResult;
678
867
  };
679
- type WebhookPayload = WebhookTaskImageCompletedPayload | WebhookTaskImageFailedPayload | WebhookTaskImageRateCompletedPayload | WebhookTaskImageRateFailedPayload | WebhookTaskImageAltCompletedPayload | WebhookTaskImageAltFailedPayload | WebhookTaskImageReviewCompletedPayload | WebhookTaskImageReviewFailedPayload | WebhookTaskImageRemoveBackgroundCompletedPayload | WebhookTaskImageRemoveBackgroundFailedPayload | WebhookTaskImageUpscaleCompletedPayload | WebhookTaskImageUpscaleFailedPayload | WebhookTaskVideoCompletedPayload | WebhookTaskVideoFailedPayload;
680
- }
868
+ };
681
869
  //#endregion
682
- export { AvailableVideoModel as a, VideoResolutionTier as c, AvailableModel as i, AVAILABLE_MODELS as n, ModelCapability as o, AVAILABLE_VIDEO_MODELS as r, VideoInputRole as s, MynthSDKTypes as t };
870
+ export { AvailableVideoModel as _, ImageRemoveBackgroundResult as a, VideoResolutionTier as b, MynthGeneratedImage as c, MynthCompletedTask as d, MynthTaskFailure as f, AvailableModel as g, AVAILABLE_VIDEO_MODELS as h, ImageReviewResult as i, MynthOutputImage as l, AVAILABLE_MODELS as m, MynthOutputVideo as n, ImageRateResult as o, MynthSDKTypes as p, ImageUpscaleResult as r, ImageGenerationResult as s, VideoGenerationResult as t, ImageAltResult as u, ModelCapability as v, VideoInputRole as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mynthio/sdk",
3
- "version": "0.0.48",
3
+ "version": "0.0.50",
4
4
  "description": "Official Mynth SDK for image generation and analysis",
5
5
  "keywords": [
6
6
  "ai",
@@ -48,6 +48,7 @@
48
48
  "@vitest/coverage-v8": "^5.0.2",
49
49
  "convex": "^1.46.0",
50
50
  "publint": "^0.3.24",
51
+ "standardwebhooks": "^1.1.1",
51
52
  "tsdown": "^0.23.0",
52
53
  "typescript": "7.0.2",
53
54
  "vitest": "^5.0.2"