vargai 0.4.0-alpha50 → 0.4.0-alpha51

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/ai-sdk/file.ts +20 -0
package/package.json CHANGED
@@ -69,7 +69,7 @@
69
69
  "sharp": "^0.34.5",
70
70
  "zod": "^4.2.1"
71
71
  },
72
- "version": "0.4.0-alpha50",
72
+ "version": "0.4.0-alpha51",
73
73
  "exports": {
74
74
  ".": "./src/index.ts",
75
75
  "./ai": "./src/ai-sdk/index.ts",
@@ -60,6 +60,18 @@ export class File {
60
60
  return new File({ url, mediaType });
61
61
  }
62
62
 
63
+ /** Hydrate a File from the render service response shape */
64
+ static fromRenderFile(input: {
65
+ url: string | null;
66
+ mediaType: string;
67
+ metadata?: FileMetadata;
68
+ }): File | null {
69
+ if (!input.url) return null;
70
+ const file = File.fromUrl(input.url, input.mediaType);
71
+ if (input.metadata) file.withMetadata(input.metadata);
72
+ return file;
73
+ }
74
+
63
75
  static fromBuffer(data: Uint8Array, mediaType: string): File {
64
76
  return new File({ data, mediaType });
65
77
  }
@@ -202,6 +214,14 @@ export class File {
202
214
  return btoa(binary);
203
215
  }
204
216
 
217
+ toJSON(): { url: string | null; mediaType: string; metadata: FileMetadata } {
218
+ return {
219
+ url: this._url,
220
+ mediaType: this._mediaType,
221
+ metadata: this._metadata,
222
+ };
223
+ }
224
+
205
225
  async toInput(): Promise<ImageModelV3File> {
206
226
  if (this._url) {
207
227
  return { type: "url", url: this._url };