From 838badc0b49d213134fb29a45179147abdd366ba Mon Sep 17 00:00:00 2001 From: badayvedat Date: Thu, 15 Feb 2024 15:41:44 +0300 Subject: [PATCH 1/3] fix: nested blob upload --- libs/client/src/storage.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/client/src/storage.ts b/libs/client/src/storage.ts index 203bbbd..60f3dce 100644 --- a/libs/client/src/storage.ts +++ b/libs/client/src/storage.ts @@ -117,6 +117,9 @@ export const storageImpl: StorageSupport = { const url = await storageImpl.upload(blob as Blob); return [key, url]; } + if (value !== null && typeof value === 'object') { + return [key, await storageImpl.transformInput(value)]; + } return [key, value] as KeyValuePair; }); const results = await Promise.all(promises); From 0d52e0f61b7f948d9b2c97da4b8b209bbe22bfc2 Mon Sep 17 00:00:00 2001 From: badayvedat Date: Thu, 15 Feb 2024 16:35:14 +0300 Subject: [PATCH 2/3] refactor: export to a utility function --- libs/client/src/storage.ts | 3 ++- libs/client/src/utils.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/client/src/storage.ts b/libs/client/src/storage.ts index 60f3dce..063a583 100644 --- a/libs/client/src/storage.ts +++ b/libs/client/src/storage.ts @@ -1,5 +1,6 @@ import { getConfig, getRestApiUrl } from './config'; import { dispatchRequest } from './request'; +import { isPlainObject } from './utils'; /** * File support for the client. This interface establishes the contract for @@ -117,7 +118,7 @@ export const storageImpl: StorageSupport = { const url = await storageImpl.upload(blob as Blob); return [key, url]; } - if (value !== null && typeof value === 'object') { + if (isPlainObject(value)) { return [key, await storageImpl.transformInput(value)]; } return [key, value] as KeyValuePair; diff --git a/libs/client/src/utils.ts b/libs/client/src/utils.ts index e3634bc..750a584 100644 --- a/libs/client/src/utils.ts +++ b/libs/client/src/utils.ts @@ -82,3 +82,12 @@ export function isReact() { } 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; +} From bcbbda4fe1bd4a39496df90d9c17870fda78c7f8 Mon Sep 17 00:00:00 2001 From: badayvedat Date: Thu, 15 Feb 2024 18:06:45 +0300 Subject: [PATCH 3/3] chore: bump version to 0.8.3 --- libs/client/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/client/package.json b/libs/client/package.json index 5c323cf..8d1f95e 100644 --- a/libs/client/package.json +++ b/libs/client/package.json @@ -1,7 +1,7 @@ { "name": "@fal-ai/serverless-client", "description": "The fal serverless JS/TS client", - "version": "0.8.2", + "version": "0.8.3", "license": "MIT", "repository": { "type": "git",