From bb4565a415837cbae416a3eae9203854f832f8a9 Mon Sep 17 00:00:00 2001 From: Inian Date: Wed, 10 Aug 2022 14:07:32 +0800 Subject: [PATCH 1/2] fix: pass through all values returned by backend instead of cherry picking only name - we still do this in the types though. also ensures data is always an object. Fixes #6 --- src/lib/StorageBucketApi.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/StorageBucketApi.ts b/src/lib/StorageBucketApi.ts index 1315dc2..e42ac92 100644 --- a/src/lib/StorageBucketApi.ts +++ b/src/lib/StorageBucketApi.ts @@ -80,7 +80,7 @@ export class StorageBucketApi { options: { public: boolean } = { public: false } ): Promise< | { - data: string + data: Pick error: null } | { @@ -95,7 +95,7 @@ export class StorageBucketApi { { id, name: id, public: options.public }, { headers: this.headers } ) - return { data: data.name, error: null } + return { data, error: null } } catch (error) { if (isStorageError(error)) { return { data: null, error } From 1c25725e4ea95ffdfe6ca02500b2c52da7f89962 Mon Sep 17 00:00:00 2001 From: Inian Date: Wed, 10 Aug 2022 14:19:24 +0800 Subject: [PATCH 2/2] fix tests --- test/storageApi.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/storageApi.test.ts b/test/storageApi.test.ts index 09a73c9..85319cd 100644 --- a/test/storageApi.test.ts +++ b/test/storageApi.test.ts @@ -31,7 +31,7 @@ test('Get bucket with wrong id', async () => { test('create new bucket', async () => { const res = await storage.createBucket(newBucketName) - expect(res.data).toEqual(newBucketName) + expect(res.data?.name).toEqual(newBucketName) }) test('create new public bucket', async () => {