fix: nested blob upload (#48)

* fix: nested blob upload

* refactor: export to a utility function

* chore: bump version to 0.8.3
This commit is contained in:
Vedat Baday 2024-02-16 03:30:00 +03:00 committed by GitHub
parent 9cc7cf5456
commit 66d817b2a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 1 deletions

View File

@ -1,7 +1,7 @@
{ {
"name": "@fal-ai/serverless-client", "name": "@fal-ai/serverless-client",
"description": "The fal serverless JS/TS client", "description": "The fal serverless JS/TS client",
"version": "0.8.2", "version": "0.8.3",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -1,5 +1,6 @@
import { getConfig, getRestApiUrl } from './config'; import { getConfig, getRestApiUrl } from './config';
import { dispatchRequest } from './request'; import { dispatchRequest } from './request';
import { isPlainObject } from './utils';
/** /**
* File support for the client. This interface establishes the contract for * File support for the client. This interface establishes the contract for
@ -117,6 +118,9 @@ export const storageImpl: StorageSupport = {
const url = await storageImpl.upload(blob as Blob); const url = await storageImpl.upload(blob as Blob);
return [key, url]; return [key, url];
} }
if (isPlainObject(value)) {
return [key, await storageImpl.transformInput(value)];
}
return [key, value] as KeyValuePair; return [key, value] as KeyValuePair;
}); });
const results = await Promise.all(promises); const results = await Promise.all(promises);

View File

@ -82,3 +82,12 @@ export function isReact() {
} }
return isRunningInReact; return isRunningInReact;
} }
/**
* Check if a value is a plain object.
* @param value - The value to check.
* @returns `true` if the value is a plain object, `false` otherwise.
*/
export function isPlainObject(value: any): boolean {
return !!value && Object.getPrototypeOf(value) === Object.prototype;
}