@vargai/gateway 0.1.4 → 0.1.5

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/dist/index.js +27 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14164,7 +14164,19 @@ class VargVideoModel {
14164
14164
  if (options.aspectRatio)
14165
14165
  params.aspect_ratio = options.aspectRatio;
14166
14166
  if (options.files && options.files.length > 0) {
14167
- params.files = options.files.filter((f) => f.type === "url").map((f) => ({ url: f.url }));
14167
+ const fileUrls = [];
14168
+ for (const f of options.files) {
14169
+ if (f.type === "url") {
14170
+ fileUrls.push({ url: f.url });
14171
+ } else if (f.type === "file") {
14172
+ const fileData = f;
14173
+ const uploaded = await this.client.uploadFile(new Blob([fileData.data], { type: fileData.mediaType }), fileData.mediaType);
14174
+ fileUrls.push({ url: uploaded.url });
14175
+ }
14176
+ }
14177
+ if (fileUrls.length > 0) {
14178
+ params.files = fileUrls;
14179
+ }
14168
14180
  }
14169
14181
  if (options.providerOptions?.varg) {
14170
14182
  params.provider_options = options.providerOptions.varg;
@@ -14201,7 +14213,19 @@ class VargImageModel {
14201
14213
  if (options.aspectRatio)
14202
14214
  params.aspect_ratio = options.aspectRatio;
14203
14215
  if (options.files && options.files.length > 0) {
14204
- params.files = options.files.filter((f) => f.type === "url").map((f) => ({ url: f.url }));
14216
+ const fileUrls = [];
14217
+ for (const f of options.files) {
14218
+ if (f.type === "url") {
14219
+ fileUrls.push({ url: f.url });
14220
+ } else if (f.type === "file") {
14221
+ const fileData = f;
14222
+ const uploaded = await this.client.uploadFile(new Blob([fileData.data], { type: fileData.mediaType }), fileData.mediaType);
14223
+ fileUrls.push({ url: uploaded.url });
14224
+ }
14225
+ }
14226
+ if (fileUrls.length > 0) {
14227
+ params.files = fileUrls;
14228
+ }
14205
14229
  }
14206
14230
  if (options.providerOptions?.varg) {
14207
14231
  params.provider_options = options.providerOptions.varg;
@@ -14242,8 +14266,7 @@ class VargSpeechModel {
14242
14266
  warnings,
14243
14267
  response: {
14244
14268
  timestamp: new Date,
14245
- modelId: this.modelId,
14246
- headers: undefined
14269
+ modelId: this.modelId
14247
14270
  }
14248
14271
  };
14249
14272
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vargai/gateway",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "typescript client for varg gateway api",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",