@fungi.computer/darkroom 0.9.1 → 0.10.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.
@@ -27,6 +27,7 @@ const mediaModelPriceEstimateSchema: ZodObject<{
27
27
  height: ZodOptional<ZodNumber>;
28
28
  steps: ZodOptional<ZodNumber>;
29
29
  durationSeconds: ZodOptional<ZodNumber>;
30
+ targetMegapixels: ZodOptional<ZodNumber>;
30
31
  voiceId: ZodOptional<ZodString>;
31
32
  resolution: ZodOptional<ZodEnum<{
32
33
  p480: "480p";
@@ -84,6 +85,7 @@ const mediaCatalogModelSchema: ZodReadonly<ZodObject<{
84
85
  height: ZodOptional<ZodNumber>;
85
86
  steps: ZodOptional<ZodNumber>;
86
87
  durationSeconds: ZodOptional<ZodNumber>;
88
+ targetMegapixels: ZodOptional<ZodNumber>;
87
89
  voiceId: ZodOptional<ZodString>;
88
90
  resolution: ZodOptional<ZodEnum<{
89
91
  p480: ...;
@@ -200,6 +202,26 @@ const mediaCatalogModelSchema: ZodReadonly<ZodObject<{
200
202
  seconds: ZodNullable<ZodReadonly<ZodObject<..., ...>>>;
201
203
  milliunitsPerUnit: ZodNumber;
202
204
  }, $strict>>>>;
205
+ billingUnit: ZodEnum<{
206
+ image: "image";
207
+ video_second: "video_second";
208
+ audio_second: "audio_second";
209
+ audio_character_block: "audio_character_block";
210
+ }>;
211
+ transform: ZodNullable<ZodLazy<ZodReadonly<ZodObject<{
212
+ operation: ZodEnum<{
213
+ remove_background: "remove_background";
214
+ upscale: "upscale";
215
+ }>;
216
+ source: ZodReadonly<ZodObject<{
217
+ formats: ...;
218
+ maxBytes: ...;
219
+ maxPixels: ...;
220
+ }, $strict>>;
221
+ defaultMegapixels: ZodNullable<ZodNumber>;
222
+ milliunits: ZodNullable<ZodNumber>;
223
+ sizes: ZodReadonly<ZodArray<ZodReadonly<...>>>;
224
+ }, $strict>>>>;
203
225
  }, $strict>>;
204
226
  ```
205
227
 
@@ -225,6 +247,7 @@ const mediaModelsSchema: ZodLazy<ZodArray<ZodReadonly<ZodObject<{
225
247
  height: ZodOptional<...>;
226
248
  steps: ZodOptional<...>;
227
249
  durationSeconds: ZodOptional<...>;
250
+ targetMegapixels: ZodOptional<...>;
228
251
  voiceId: ZodOptional<...>;
229
252
  resolution: ZodOptional<...>;
230
253
  aspectRatio: ZodOptional<...>;
@@ -306,6 +329,19 @@ const mediaModelsSchema: ZodLazy<ZodArray<ZodReadonly<ZodObject<{
306
329
  seconds: ZodNullable<...>;
307
330
  milliunitsPerUnit: ZodNumber;
308
331
  }, $strict>>>>;
332
+ billingUnit: ZodEnum<{
333
+ image: "image";
334
+ video_second: "video_second";
335
+ audio_second: "audio_second";
336
+ audio_character_block: "audio_character_block";
337
+ }>;
338
+ transform: ZodNullable<ZodLazy<ZodReadonly<ZodObject<{
339
+ operation: ZodEnum<...>;
340
+ source: ZodReadonly<...>;
341
+ defaultMegapixels: ZodNullable<...>;
342
+ milliunits: ZodNullable<...>;
343
+ sizes: ZodReadonly<...>;
344
+ }, $strict>>>>;
309
345
  }, $strict>>>>;
310
346
  ```
311
347
 
@@ -615,6 +651,13 @@ const appMediaModelsOutcomeSchema: ZodUnion<readonly [ZodLazy<ZodArray<ZodReadon
615
651
  sizes: ZodNullable<ZodReadonly<ZodArray<ZodString>>>;
616
652
  video: ZodNullable<ZodLazy<ZodReadonly<ZodObject<..., ...>>>>;
617
653
  audio: ZodNullable<ZodLazy<ZodReadonly<ZodObject<..., ...>>>>;
654
+ billingUnit: ZodEnum<{
655
+ image: "image";
656
+ video_second: "video_second";
657
+ audio_second: "audio_second";
658
+ audio_character_block: "audio_character_block";
659
+ }>;
660
+ transform: ZodNullable<ZodLazy<ZodReadonly<ZodObject<..., ...>>>>;
618
661
  }, $strict>>>>, ZodUnion<readonly [ZodObject<{
619
662
  error: ZodEnum<{
620
663
  revoked: "revoked";
@@ -78,6 +78,17 @@ const mediaFailureSchema: ZodObject<{
78
78
  Sanitized HTTP refusal emitted by a Media host and decoded at the browser
79
79
  boundary.
80
80
 
81
+ ---
82
+
83
+ ### backgroundProviderTimeoutMs
84
+
85
+ ```ts
86
+ const backgroundProviderTimeoutMs: number;
87
+ ```
88
+
89
+ The longest a background provider call runs before it is cut off, safely inside
90
+ the 15-minute alarm wall-clock limit that would kill the call.
91
+
81
92
  ## Functions
82
93
 
83
94
  ### readMediaFailure()
@@ -90,12 +101,12 @@ function readMediaFailure(
90
101
  error: string;
91
102
  stage:
92
103
  | "provider"
104
+ | "operation"
93
105
  | "admission"
94
106
  | "generation-authorization"
95
107
  | "settings"
96
108
  | "estimate"
97
109
  | "billing"
98
- | "operation"
99
110
  | "normalization"
100
111
  | "artifact"
101
112
  | "destination-authorization"
@@ -125,9 +136,9 @@ Read and decode one Media host failure at the browser HTTP boundary.
125
136
 
126
137
  #### Returns
127
138
 
128
- `Promise`\< \| \{ `error`: `string`; `stage`: \| `"provider"` \| `"admission"`
129
- \| `"generation-authorization"` \| `"settings"` \| `"estimate"` \| `"billing"`
130
- \| `"operation"` \| `"normalization"` \| `"artifact"` \|
139
+ `Promise`\< \| \{ `error`: `string`; `stage`: \| `"provider"` \| `"operation"`
140
+ \| `"admission"` \| `"generation-authorization"` \| `"settings"` \| `"estimate"`
141
+ \| `"billing"` \| `"normalization"` \| `"artifact"` \|
131
142
  `"destination-authorization"` \| `"destination-write"`; `code`: \|
132
143
  `"CAPABILITY_DENIED"` \| `"DAILY_LIMIT_REACHED"` \| `"INSUFFICIENT_CREDIT"` \|
133
144
  `"HOST_FAILURE"` \| `"INVALID_ARGUMENT"` \| `"MEDIA_PROVIDER_FAILURE"` \|
@@ -600,6 +600,94 @@ Dispatch to the native Workers AI binding.
600
600
 
601
601
  ---
602
602
 
603
+ ### MediaR2Bucket
604
+
605
+ ```ts
606
+ type MediaR2Bucket = object;
607
+ ```
608
+
609
+ The R2 bucket operations a Media destination needs; a native `R2Bucket`
610
+ satisfies it.
611
+
612
+ #### Methods
613
+
614
+ ##### get()
615
+
616
+ ```ts
617
+ get(key): Promise<
618
+ | Readonly<{
619
+ size: number;
620
+ }> & object
621
+ | null>;
622
+ ```
623
+
624
+ Read one object, or null when the key is absent.
625
+
626
+ ###### Parameters
627
+
628
+ | Parameter | Type |
629
+ | --------- | -------- |
630
+ | `key` | `string` |
631
+
632
+ ###### Returns
633
+
634
+ `Promise`\< \| `Readonly`\<\{ `size`: `number`; \}\> & `object` \| `null`\>
635
+
636
+ ##### put()
637
+
638
+ ```ts
639
+ put(
640
+ key,
641
+ bytes,
642
+ options
643
+ ): Promise<object | null>;
644
+ ```
645
+
646
+ Store exact bytes with their MIME type.
647
+
648
+ ###### Parameters
649
+
650
+ | Parameter | Type |
651
+ | --------- | --------------------------------------------------------------------------------- |
652
+ | `key` | `string` |
653
+ | `bytes` | `Uint8Array` |
654
+ | `options` | `Readonly`\<\{ `httpMetadata`: `Readonly`\<\{ `contentType`: `string`; \}\>; \}\> |
655
+
656
+ ###### Returns
657
+
658
+ `Promise`\<`object` \| `null`\>
659
+
660
+ ---
661
+
662
+ ### R2MediaDestinationOptions
663
+
664
+ ```ts
665
+ type R2MediaDestinationOptions = Readonly<{
666
+ bucket: MediaR2Bucket;
667
+ destinationId: string;
668
+ fit: ReferenceImageFitter;
669
+ authorize?: (key) => Promise<void> | void;
670
+ }>;
671
+ ```
672
+
673
+ Host-owned R2 destination configuration.
674
+
675
+ ---
676
+
677
+ ### R2MediaDestination
678
+
679
+ ```ts
680
+ type R2MediaDestination = MediaServiceHost["destination"] &
681
+ Readonly<{
682
+ readReference: (reference, model) => Promise<MediaReferenceBytes>;
683
+ readAudioReference: (reference) => Promise<Uint8Array>;
684
+ }>;
685
+ ```
686
+
687
+ The host destination over an R2 bucket, with both reference readers present.
688
+
689
+ ---
690
+
603
691
  ### MediaImagePort
604
692
 
605
693
  ```ts
@@ -708,6 +796,27 @@ AI Gateway route.
708
796
 
709
797
  ---
710
798
 
799
+ ### createR2MediaDestination()
800
+
801
+ ```ts
802
+ function createR2MediaDestination(options): R2MediaDestination;
803
+ ```
804
+
805
+ A Media destination over one R2 bucket: object keys are the paths, validated
806
+ with Darkroom's path schema. Never accepts URLs.
807
+
808
+ #### Parameters
809
+
810
+ | Parameter | Type |
811
+ | --------- | --------------------------------------------------------- |
812
+ | `options` | [`R2MediaDestinationOptions`](#r2mediadestinationoptions) |
813
+
814
+ #### Returns
815
+
816
+ [`R2MediaDestination`](#r2mediadestination)
817
+
818
+ ---
819
+
711
820
  ### createImagesReferenceFitter()
712
821
 
713
822
  ```ts